@Test public void testReduceToFieldSpec_withNull_reducesToSpec() { DateTimeGranularity offsetGranularity = DateTimeGranularity.create("MILLIS"); FieldSpecRelation beforeDateRelations = new BeforeRelation(a, b, true, DateTimeDefaults.get(), offsetGranularity, 0); OffsetDateTime value = null; DataBagValue generatedValue = new DataBagValue(value); FieldSpec result = beforeDateRelations.createModifierFromOtherValue(generatedValue); FieldSpec expected = FieldSpecFactory.fromType(FieldType.DATETIME); assertEquals(expected, result); }
@Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { if (otherFieldGeneratedValue.getValue() == null) return FieldSpecFactory.fromType(main.getType()); T offsetValue = offset > 0 ? offsetGranularity.getPrevious((T) otherFieldGeneratedValue.getValue(), offset) : (T) otherFieldGeneratedValue.getValue(); return createFromMax(offsetValue, defaults.granularity()); }
BeforeRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { if (otherFieldGeneratedValue.getValue() == null) return FieldSpecFactory.fromType(main.getType()); T offsetValue = offset > 0 ? offsetGranularity.getPrevious((T) otherFieldGeneratedValue.getValue(), offset) : (T) otherFieldGeneratedValue.getValue(); return createFromMax(offsetValue, defaults.granularity()); } }
BeforeRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { if (otherFieldGeneratedValue.getValue() == null) return FieldSpecFactory.fromType(main.getType()); T offsetValue = offset > 0 ? offsetGranularity.getPrevious((T) otherFieldGeneratedValue.getValue(), offset) : (T) otherFieldGeneratedValue.getValue(); return createFromMax(offsetValue, defaults.granularity()); } BeforeRelation(Field main, Field other, boolean inclusive, LinearDefaults<T> defaults, Granularity<T> offsetGranularity, int offset); }
BeforeRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { if (otherFieldGeneratedValue.getValue() == null) return FieldSpecFactory.fromType(main.getType()); T offsetValue = offset > 0 ? offsetGranularity.getPrevious((T) otherFieldGeneratedValue.getValue(), offset) : (T) otherFieldGeneratedValue.getValue(); return createFromMax(offsetValue, defaults.granularity()); } BeforeRelation(Field main, Field other, boolean inclusive, LinearDefaults<T> defaults, Granularity<T> offsetGranularity, int offset); @Override FieldSpec createModifierFromOtherFieldSpec(FieldSpec otherFieldSpec); @Override FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue); @Override Field main(); @Override Field other(); @Override FieldSpecRelation inverse(); @Override String toString(); @Override Constraint negate(); }
BeforeRelation implements FieldSpecRelation { @Override public FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue) { if (otherFieldGeneratedValue.getValue() == null) return FieldSpecFactory.fromType(main.getType()); T offsetValue = offset > 0 ? offsetGranularity.getPrevious((T) otherFieldGeneratedValue.getValue(), offset) : (T) otherFieldGeneratedValue.getValue(); return createFromMax(offsetValue, defaults.granularity()); } BeforeRelation(Field main, Field other, boolean inclusive, LinearDefaults<T> defaults, Granularity<T> offsetGranularity, int offset); @Override FieldSpec createModifierFromOtherFieldSpec(FieldSpec otherFieldSpec); @Override FieldSpec createModifierFromOtherValue(DataBagValue otherFieldGeneratedValue); @Override Field main(); @Override Field other(); @Override FieldSpecRelation inverse(); @Override String toString(); @Override Constraint negate();  }