Class LabelCardinalityValidator
java.lang.Object
org.apache.tinkerpop.gremlin.structure.util.LabelCardinalityValidator
Validates label operations against a
LabelCardinality constraint. All methods are stateless and static.
This class is separated from the enum so that cardinality remains a pure data descriptor while validation logic can be extended, overridden by providers, or tested independently.
- Since:
- 4.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidvalidateAdd(LabelCardinality cardinality, Set<String> currentLabels, String label, String... moreLabels) Validates that adding labels would not violate cardinality constraints.static voidvalidateCreation(LabelCardinality cardinality, Set<String> labels) Validates that a set of labels is valid for element creation under this cardinality.static voidvalidateDrop(LabelCardinality cardinality, Set<String> currentLabels, String label, String... moreLabels) Validates that dropping specific labels would not violate cardinality constraints.static voidvalidateDropAll(LabelCardinality cardinality, Set<String> currentLabels) Validates that dropping all labels would not violate cardinality constraints.
-
Method Details
-
validateAdd
public static void validateAdd(LabelCardinality cardinality, Set<String> currentLabels, String label, String... moreLabels) Validates that adding labels would not violate cardinality constraints.- Throws:
IllegalStateException- if mutation is not supported or max would be exceeded
-
validateDrop
public static void validateDrop(LabelCardinality cardinality, Set<String> currentLabels, String label, String... moreLabels) Validates that dropping specific labels would not violate cardinality constraints. Simulates the removal to check whether the minimum label count would be violated.- Throws:
IllegalStateException- if mutation is not supported or min would be violated
-
validateDropAll
Validates that dropping all labels would not violate cardinality constraints.- Throws:
IllegalStateException- if mutation is not supported or min > 0
-
validateCreation
Validates that a set of labels is valid for element creation under this cardinality.- Throws:
IllegalStateException- if the label count violates min or max
-