@Test public void testRejectsPartitionFieldSchemaMismatch() { TestHelpers.assertThrows("Should reject incorrect schema, string for int", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("year", "joker"); } }); TestHelpers.assertThrows("Should reject incorrect schema, int for string", IllegalArgumentException.class, new Runnable() { @Override public void run() { emptyConstraints.with("id", 34); } }); }
@SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } }
Constraints { @SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } } }
Constraints { @SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } } Constraints(Schema schema);  Constraints(Schema schema, PartitionStrategy strategy); private  Constraints(Schema schema, PartitionStrategy strategy,
                      Map<String, Predicate> constraints,
                      Map<String, Object> provided); private  Constraints(Constraints copy, String name, Predicate predicate); private  Constraints(Constraints copy,
                      String name, Predicate predicate, Object value); }
Constraints { @SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } } Constraints(Schema schema);  Constraints(Schema schema, PartitionStrategy strategy); private  Constraints(Schema schema, PartitionStrategy strategy,
                      Map<String, Predicate> constraints,
                      Map<String, Object> provided); private  Constraints(Constraints copy, String name, Predicate predicate); private  Constraints(Constraints copy,
                      String name, Predicate predicate, Object value); Predicate<E> toEntityPredicate(EntityAccessor<E> accessor); Predicate<E> toEntityPredicate(StorageKey key, EntityAccessor<E> accessor); Iterator<E> filter(Iterator<E> iterator, EntityAccessor<E> accessor); KeyPredicate toKeyPredicate(); Iterable<MarkerRange> toKeyRanges(); @SuppressWarnings("unchecked") boolean alignedWithBoundaries(); Map<String, Object> getProvidedValues(); @SuppressWarnings("unchecked") Constraints with(String name, Object... values); Constraints from(String name, Comparable value); Constraints fromAfter(String name, Comparable value); Constraints to(String name, Comparable value); Constraints toBefore(String name, Comparable value); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Map<String, String> toQueryMap(); Map<String, String> toNormalizedQueryMap(); static Constraints fromQueryMap(Schema schema,
                                         PartitionStrategy strategy,
                                         Map<String, String> query); boolean isUnbounded(); }
Constraints { @SuppressWarnings("unchecked") public Constraints with(String name, Object... values) { SchemaUtil.checkTypeConsistency(schema, strategy, name, values); if (values.length > 0) { checkContained(name, values); In added = Predicates.in(values); if (values.length == 1) { return new Constraints(this, name, added, values[0]); } else { return new Constraints(this, name, added); } } else { if (!constraints.containsKey(name)) { return new Constraints(this, name, Predicates.exists()); } else { return this; } } } Constraints(Schema schema);  Constraints(Schema schema, PartitionStrategy strategy); private  Constraints(Schema schema, PartitionStrategy strategy,
                      Map<String, Predicate> constraints,
                      Map<String, Object> provided); private  Constraints(Constraints copy, String name, Predicate predicate); private  Constraints(Constraints copy,
                      String name, Predicate predicate, Object value); Predicate<E> toEntityPredicate(EntityAccessor<E> accessor); Predicate<E> toEntityPredicate(StorageKey key, EntityAccessor<E> accessor); Iterator<E> filter(Iterator<E> iterator, EntityAccessor<E> accessor); KeyPredicate toKeyPredicate(); Iterable<MarkerRange> toKeyRanges(); @SuppressWarnings("unchecked") boolean alignedWithBoundaries(); Map<String, Object> getProvidedValues(); @SuppressWarnings("unchecked") Constraints with(String name, Object... values); Constraints from(String name, Comparable value); Constraints fromAfter(String name, Comparable value); Constraints to(String name, Comparable value); Constraints toBefore(String name, Comparable value); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Map<String, String> toQueryMap(); Map<String, String> toNormalizedQueryMap(); static Constraints fromQueryMap(Schema schema,
                                         PartitionStrategy strategy,
                                         Map<String, String> query); boolean isUnbounded();  }