Class Index.Builder<V>

  • Type Parameters:
    V - the entry type
    Direct Known Subclasses:
    Index.Mutable.Builder
    Enclosing interface:
    Index<V>

    public static class Index.Builder<V>
    extends java.lang.Object
    Builder of Index instances.
    • Constructor Summary

      Constructors 
      Constructor Description
      Builder()
      Create a new index builder instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Index<V> build()
      Build a Index instance.
      Index.Builder<V> caseSensitive​(boolean caseSensitive)
      Configure the index to be either case-sensitive or not.
      Index.Mutable.Builder<V> mutable()
      Configure the index to be mutable.
      Index.Builder<V> with​(java.lang.String key, V value)
      Configure a pre-existing entry.
      Index.Builder<V> with​(V value)
      Configure a pre-existing entry with a key that is the Object.toString() representation of the value.
      Index.Builder<V> withAll​(java.util.function.Supplier<java.util.Map<java.lang.String,​V>> entriesSupplier)
      Configure some pre-existing entries.
      Index.Builder<V> withAll​(V[] values, java.util.function.Function<V,​java.lang.String> keyFunction)
      Configure some pre-existing entries.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Builder

        public Builder()
        Create a new index builder instance.
    • Method Detail

      • caseSensitive

        public Index.Builder<V> caseSensitive​(boolean caseSensitive)
        Configure the index to be either case-sensitive or not. Default value is false.
        Parameters:
        caseSensitive - true if the index has to be case-sensitive
        Returns:
        this
      • withAll

        public Index.Builder<V> withAll​(V[] values,
                                        java.util.function.Function<V,​java.lang.String> keyFunction)
        Configure some pre-existing entries.
        Parameters:
        values - an array of values
        keyFunction - a Function that generates the key of each entry of the values array
        Returns:
        this
      • withAll

        public Index.Builder<V> withAll​(java.util.function.Supplier<java.util.Map<java.lang.String,​V>> entriesSupplier)
        Configure some pre-existing entries.
        Parameters:
        entriesSupplier - a Map Supplier of entries
        Returns:
        this
      • with

        public Index.Builder<V> with​(V value)
        Configure a pre-existing entry with a key that is the Object.toString() representation of the value.
        Parameters:
        value - The value
        Returns:
        this
      • with

        public Index.Builder<V> with​(java.lang.String key,
                                     V value)
        Configure a pre-existing entry.
        Parameters:
        key - The key
        value - The value for the key string
        Returns:
        this
      • build

        public Index<V> build()
        Build a Index instance.
        Returns:
        a Index instance.