java.lang.Object
ac.simons.neo4j.migrations.core.catalog.Index
All Implemented Interfaces:
CatalogItem<Index.Type>, Formattable

public final class Index extends Object
A somewhat Neo4j version independent representation of an index.
Since:
1.7.0
Author:
Michael J. Simons, Gerrit Meier
  • Field Details

    • options

      protected final String options
      Any additional options to be passed to the item. Might be null.
  • Method Details

    • forNode

      public static Index.Builder forNode(String label)
      Starts defining a new instance of a node index.
      Parameters:
      label - The label on which the index should be applied
      Returns:
      The ongoing builder
    • forNode

      public static Index.FulltextBuilder forNode(String... labels)
      Starts defining a new instance of a node index.
      Parameters:
      labels - The labels on which the index should be applied
      Returns:
      The ongoing builder
    • forRelationship

      public static Index.Builder forRelationship(String type)
      Starts defining a new instance of a node index.
      Parameters:
      type - The type on which the index should be applied
      Returns:
      The ongoing builder
    • forRelationship

      public static Index.FulltextBuilder forRelationship(String... types)
      Starts defining a new instance of a relationship index.
      Parameters:
      types - The type on which the index should be applied
      Returns:
      The ongoing builder
    • parse

      public static Index parse(Element indexElement)
      Creates an index from a xml definition.
      Parameters:
      indexElement - as defined in migration.xsd.
      Returns:
      The new index if the element as parseable
    • parse

      public static Index parse(org.neo4j.driver.types.MapAccessor row)
      Parses an index from a MapAccessor
      Parameters:
      row - the result row
      Returns:
      An index
      Throws:
      IllegalArgumentException - if the row cannot be processed
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withName

      public Index withName(String newName)
      Description copied from interface: CatalogItem
      Creates a copy of this item with the specific name. Will return this instance if the name has not changed.
      Parameters:
      newName - The new name to use
      Returns:
      A (potentially) new item
    • withOptions

      public Index withOptions(String newOptions)
      Creates a copy of this index with the specific set of options added. Will return this instance if the options are identical to current options.
      Parameters:
      newOptions - The new options to use
      Returns:
      A (potentially) new index
      Since:
      1.13.0
    • withType

      public Index withType(Index.Type newType)
      Creates a copy of this index with the given type. Will return this instance if the type is identical to the current one.
      Parameters:
      newType - The new type to use
      Returns:
      A (potentially) new index
      Since:
      1.13.0
    • isEquivalentTo

      public boolean isEquivalentTo(CatalogItem<?> that)
      true, if item is an index of the same type for the same entity containing the same properties. Also index name and options will be compared.
      Parameters:
      that - the other item to compare to
      Returns:
      true if this and the other item are equivalent
    • getName

      public Name getName()
      Specified by:
      getName in interface CatalogItem<T extends ItemType>
      Returns:
      A unique name for a catalog item.
    • getType

      public Index.Type getType()
      Specified by:
      getType in interface CatalogItem<T extends ItemType>
      Returns:
      Type information for the given item, specialized to the item type itself.
    • getTargetEntityType

      public TargetEntityType getTargetEntityType()
      Returns:
      The target entity of this item.
    • getIdentifier

      public String getIdentifier()
      Returns:
      Identifier of this item to be used in create statements
    • getProperties

      public Set<String> getProperties()
      Returns:
      Set of properties to be included with the item
    • getOptionalOptions

      public Optional<String> getOptionalOptions()
      Returns:
      Optional options to be passed down during creation of the item
    • hasGeneratedName

      public boolean hasGeneratedName()
      Specified by:
      hasGeneratedName in interface CatalogItem<T extends ItemType>
      Returns:
      true if this item has a generated name.
    • formatTo

      public final void formatTo(Formatter formatter, int flags, int width, int precision)
      Specified by:
      formatTo in interface Formattable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object