smiklosovic commented on code in PR #3903: URL: https://github.com/apache/cassandra/pull/3903#discussion_r1963073123
########## src/java/org/apache/cassandra/cql3/constraints/ColumnConstraint.java: ########## @@ -46,32 +53,57 @@ public enum ConstraintType // The order of that enum matters!! // We are serializing its enum position instead of its name. // Changing this enum would affect how that int is interpreted when deserializing. - COMPOSED(ColumnConstraints.serializer), - FUNCTION(FunctionColumnConstraint.serializer), - SCALAR(ScalarColumnConstraint.serializer), - UNARY_FUNCTION(UnaryFunctionColumnConstraint.serializer); + COMPOSED(ColumnConstraints.serializer, new DuplicatesChecker()), + FUNCTION(FunctionColumnConstraint.serializer, FunctionColumnConstraint.Functions.values()), + SCALAR(ScalarColumnConstraint.serializer, new ScalarColumnConstraintSatisfiabilityChecker()), + UNARY_FUNCTION(UnaryFunctionColumnConstraint.serializer, UnaryFunctionColumnConstraint.Functions.values()); private final MetadataSerializer<?> serializer; + private final SatisfiabilityChecker[] satisfiabilityCheckers; + + ConstraintType(MetadataSerializer<?> serializer, SatisfiabilityChecker satisfiabilityChecker) + { + this(serializer, new SatisfiabilityChecker[]{ satisfiabilityChecker }); + } - ConstraintType(MetadataSerializer<?> serializer) + ConstraintType(MetadataSerializer<?> serializer, SatisfiabilityChecker[] satisfiabilityCheckers) { this.serializer = serializer; + this.satisfiabilityCheckers = satisfiabilityCheckers; } public static MetadataSerializer<?> getSerializer(int i) { return ConstraintType.values()[i].serializer; } + + private static SatisfiabilityChecker[] getSatisfiabilityCheckers() + { + List<SatisfiabilityChecker> result = new ArrayList<>(); + for (ConstraintType constraintType : ConstraintType.values()) + result.addAll(Arrays.asList(constraintType.satisfiabilityCheckers)); + + return result.toArray(new SatisfiabilityChecker[0]); + } + } + + public abstract String name(); + + public String fullName() + { + return name(); } public abstract MetadataSerializer<T> serializer(); public abstract void appendCqlTo(CqlBuilder builder); + public abstract boolean enablesDuplicateDefinitions(String name); + /** * Method that evaluates the condition. It can either succeed or throw a {@link ConstraintViolationException}. * - * @param valueType value type of the column value under test + * @param valueType value type of the column value under test Review Comment: @bbotella This is how IDEA formats it, it will align the comments below each other, depending on what the longest parameter name is for that method. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org