ValidationUtils { public static <T, R> boolean isChanged(Function<T, R> getter, T newItem, T beforeChange) { if (beforeChange == null) { return true; } R after = getter.apply(newItem); R before = getter.apply(beforeChange); if (after == null) { return before != null; } else { return !after.equals(before); } } private  ValidationUtils(); static void validateBarcodeUniqueness(T barcodable, T beforeChange,
      WhineyFunction<String, T> lookupByBarcode,
      Collection<ValidationError> errors, String typeLabel); static void validateConcentrationUnits(BigDecimal concentration, ConcentrationUnit units, String field, String label,
      Collection<ValidationError> errors); static void validateConcentrationUnits(BigDecimal concentration, ConcentrationUnit units, Collection<ValidationError> errors); static void validateVolumeUnits(BigDecimal volume, VolumeUnit units, Collection<ValidationError> errors); static void validateUnboxableFields(Boxable item, Collection<ValidationError> errors); static void validateUrl(String fieldName, String maybeUrl, boolean allowEmptyUrl, Collection<ValidationError> errors); static void validateNameOrThrow(Nameable object, NamingScheme namingScheme); static boolean isSetAndChanged(Function<T, R> getter, T newItem, T beforeChange); static boolean isChanged(Function<T, R> getter, T newItem, T beforeChange); static void loadChildEntity(Consumer<T> setter, T childEntity, ProviderService<T> service,
      String property); static void applySetChanges(Set<T> to, Set<T> from); static ValidationException rewriteParentErrors(ValidationException original); static ValidationError makeNoNullError(String property);  }
@Test public void testIsChanged() { testIsChanged(true, new TestObject(null), null); testIsChanged(true, new TestObject(1), null); testIsChanged(false, new TestObject(null), new TestObject(null)); testIsChanged(false, new TestObject(1), new TestObject(1)); testIsChanged(true, new TestObject(1), new TestObject(null)); testIsChanged(true, new TestObject(null), new TestObject(1)); testIsChanged(true, new TestObject(1), new TestObject(2)); }