public Constraints fromAfter(String name, Comparable value) { SchemaUtil.checkTypeConsistency(schema, strategy, name, value); checkContained(name, value); Range added = Ranges.greaterThan(value); return new Constraints(this, name, combine(constraints.get(name), added)); }
public Constraints from(String name, Comparable value) { SchemaUtil.checkTypeConsistency(schema, strategy, name, value); checkContained(name, value); Range added = Ranges.atLeast(value); return new Constraints(this, name, combine(constraints.get(name), added)); }
public Constraints to(String name, Comparable value) { SchemaUtil.checkTypeConsistency(schema, strategy, name, value); checkContained(name, value); Range added = Ranges.atMost(value); return new Constraints(this, name, combine(constraints.get(name), added)); }
public Constraints toBefore(String name, Comparable value) { SchemaUtil.checkTypeConsistency(schema, strategy, name, value); checkContained(name, value); Range added = Ranges.lessThan(value); return new Constraints(this, name, combine(constraints.get(name), added)); }
@SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); // this is the most specific constraint and is idempotent under "and" In added = Predicates.in(values); if (values.length == 1) { // if there is only one value, it is a provided value return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { // no other constraint => add the exists return new Constraints(this, name, Predicates.exists()); } else { // satisfied by an existing constraint return this; } } }