Class Constraint
java.lang.Object
ac.simons.neo4j.migrations.core.catalog.Constraint
- All Implemented Interfaces:
CatalogItem<Constraint.Type>
,Formattable
A somewhat Neo4j version independent representation of a constraint.
- Since:
- 1.7.0
- Author:
- Michael J. Simons
- Soundtrack
- Metallica - Ride The Lightning
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Constraints available for both nodes and relationships.static interface
Allows to specify the type of the constraint.static interface
Programmatic way of defining constraints for nodes.static interface
Programmatic way of defining constraints for relationships.static enum
Enumerates the different kinds of constraints. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
final void
Starts defining a new instance of a node constraint.forRelationship
(String type) Starts defining a new instance of a relationship constraint.getName()
getType()
boolean
int
hashCode()
boolean
isEquivalentTo
(CatalogItem<?> that) true, if item is a constraint of the same type for the same entity containing the same properties.static Constraint
parse
(org.neo4j.driver.types.MapAccessor row) Parses a constraint from aMapAccessor
, which will either contain a result fromcall db.constraints()
(Neo4j 3.5 upto 4.1) or fromSHOW CONSTRAINTS YIELD *
from Neo4j 4.2 and upwardsstatic Constraint
Creates a constraint from a xml definition.Creates a copy of this item with the specific name.withOptions
(String options) Creates a copy of this constraint with the specific set of options added.
-
Field Details
-
options
Any additional options to be passed to the item. Might be null.
-
-
Method Details
-
forNode
Starts defining a new instance of a node constraint.- Parameters:
label
- The label on which the constraint should be applied- Returns:
- The ongoing builder
-
forRelationship
Starts defining a new instance of a relationship constraint.- Parameters:
type
- The type on which the constraint should be applied- Returns:
- The ongoing builder
-
parse
Parses a constraint from aMapAccessor
, which will either contain a result fromcall db.constraints()
(Neo4j 3.5 upto 4.1) or fromSHOW CONSTRAINTS YIELD *
from Neo4j 4.2 and upwards- Parameters:
row
- the result row- Returns:
- A constraint
- Throws:
IllegalArgumentException
- if the row cannot be processed
-
parse
Creates a constraint from a xml definition.- Parameters:
constraintElement
- as defined inmigration.xsd
.- Returns:
- The new constraint if the element as parseable
-
withOptions
Creates a copy of this constraint with the specific set of options added. Will return this instance if the options are identical to current options- Parameters:
options
- The new options to use- Returns:
- A (potentially) new constraint
- Since:
- 1.13.0
-
withName
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:
name
- The new name to use- Returns:
- A (potentially) new item
-
isEquivalentTo
true, if item is a constraint of the same type for the same entity containing the same properties.- Parameters:
that
- the other item to compare to- Returns:
- true if this and the other item are equivalent
-
getName
- Specified by:
getName
in interfaceCatalogItem<T extends ItemType>
- Returns:
- A unique name for a catalog item.
-
getType
- Specified by:
getType
in interfaceCatalogItem<T extends ItemType>
- Returns:
- Type information for the given item, specialized to the item type itself.
-
getTargetEntityType
- Returns:
- The target entity of this item.
-
getIdentifier
- Returns:
- Identifier of this item to be used in create statements
-
getProperties
- Returns:
- Set of properties to be included with the item
-
getOptionalOptions
- Returns:
- Optional options to be passed down during creation of the item
-
hasGeneratedName
public boolean hasGeneratedName()- Specified by:
hasGeneratedName
in interfaceCatalogItem<T extends ItemType>
- Returns:
- true if this item has a generated name.
-
formatTo
- Specified by:
formatTo
in interfaceFormattable
-
equals
-
hashCode
public int hashCode()
-