@Test public void testGetUpdatedFieldsArray() { final SystemCodes oldsc = new SystemCodes("categoryold","keyold","valueold"); final SystemCodes newsc = new SystemCodes("categorynew","keynew","valuenew"); final SystemCodes samesc = new SystemCodes("categoryold","keysame","valuesame"); final List<SystemCodes> oldFaves = new ArrayList<SystemCodes>(); oldFaves.add(samesc); oldFaves.add(oldsc); final List<SystemCodes> newFaves = new ArrayList<SystemCodes>(); newFaves.add(newsc); newFaves.add(samesc); final UserCriteria oldUser = new UserCriteria(); final UserCriteria newUser = new UserCriteria(); oldUser.setFavorites(oldFaves); newUser.setFavorites(oldFaves); Assert.assertEquals(new ArrayList<String>(), CrudUtil.getUpdatedFields(oldUser, newUser)); newUser.setFavorites(newFaves); Assert.assertEquals(Arrays.asList("favorites"), CrudUtil.getUpdatedFields(oldUser, newUser)); }
public static List<String> getUpdatedFields(final BaseEntity oldObject, final BaseEntity newObject) { final List<String> fields = CacheUtil.getSynchronizableFields(oldObject); final List<String> updatedFields = new ArrayList<String>(); for (final String field : fields) { Object oldValue = retrieveNullableObjectValue(oldObject, field); Object newValue = retrieveNullableObjectValue(newObject, field); oldValue = normalizeValue(oldValue); newValue = normalizeValue(newValue); if (!oldValue.equals(newValue)) { updatedFields.add(field); } } return updatedFields; }
CrudUtil { public static List<String> getUpdatedFields(final BaseEntity oldObject, final BaseEntity newObject) { final List<String> fields = CacheUtil.getSynchronizableFields(oldObject); final List<String> updatedFields = new ArrayList<String>(); for (final String field : fields) { Object oldValue = retrieveNullableObjectValue(oldObject, field); Object newValue = retrieveNullableObjectValue(newObject, field); oldValue = normalizeValue(oldValue); newValue = normalizeValue(newValue); if (!oldValue.equals(newValue)) { updatedFields.add(field); } } return updatedFields; } }
CrudUtil { public static List<String> getUpdatedFields(final BaseEntity oldObject, final BaseEntity newObject) { final List<String> fields = CacheUtil.getSynchronizableFields(oldObject); final List<String> updatedFields = new ArrayList<String>(); for (final String field : fields) { Object oldValue = retrieveNullableObjectValue(oldObject, field); Object newValue = retrieveNullableObjectValue(newObject, field); oldValue = normalizeValue(oldValue); newValue = normalizeValue(newValue); if (!oldValue.equals(newValue)) { updatedFields.add(field); } } return updatedFields; } private  CrudUtil(); }
CrudUtil { public static List<String> getUpdatedFields(final BaseEntity oldObject, final BaseEntity newObject) { final List<String> fields = CacheUtil.getSynchronizableFields(oldObject); final List<String> updatedFields = new ArrayList<String>(); for (final String field : fields) { Object oldValue = retrieveNullableObjectValue(oldObject, field); Object newValue = retrieveNullableObjectValue(newObject, field); oldValue = normalizeValue(oldValue); newValue = normalizeValue(newValue); if (!oldValue.equals(newValue)) { updatedFields.add(field); } } return updatedFields; } private  CrudUtil(); static String buildCreateMessage(final BaseEntity obj); static List<String> getUpdatedFields(final BaseEntity oldObject,
			final BaseEntity newObject); static String convertAuditableFieldsToJson(BaseEntity obj); @SuppressWarnings({ "rawtypes", "unchecked" }) static String buildUpdateMessage(final BaseEntity oldObject,
			final BaseEntity newObject); static String buildDeleteMessage(final BaseEntity obj); static Map<String, Object> buildMapValues(final BaseEntity object); @SuppressWarnings("rawtypes") static Map<String, Object> buildMapValues(final BaseEntity object,
			final List<String> fields); static String buildURLParameters(final BaseEntity object); @SuppressWarnings("rawtypes") static String buildJpaQueryString(final BaseEntity example,
			final boolean exactMatch); @SuppressWarnings("rawtypes") static Object retrieveObjectValue(final Object obj,
			final String property); static Object retrieveNullableObjectValue(final Object obj,
			final String property); static Class<?> retrieveObjectType(final Object obj,
			final String property); static Boolean evaluateExpression(final Object obj,
			final String expression); @SuppressWarnings("unchecked") static String replaceSQLParameters(String sql, final Object obj); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz,
			final boolean includeParent); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz,
			final boolean includeParent); static List<MessageResponse> convertErrorMessage(
			final BindingResult bindingResult, final Locale locale,
			final MessageSource messageSource); static List<MessageResponse> buildSuccessMessage(
			final BaseEntity object, final String code, final Locale locale,
			final MessageSource messageSource); static boolean isCollection(final Object ob); static BaseEntity clone(final BaseEntity source); }
CrudUtil { public static List<String> getUpdatedFields(final BaseEntity oldObject, final BaseEntity newObject) { final List<String> fields = CacheUtil.getSynchronizableFields(oldObject); final List<String> updatedFields = new ArrayList<String>(); for (final String field : fields) { Object oldValue = retrieveNullableObjectValue(oldObject, field); Object newValue = retrieveNullableObjectValue(newObject, field); oldValue = normalizeValue(oldValue); newValue = normalizeValue(newValue); if (!oldValue.equals(newValue)) { updatedFields.add(field); } } return updatedFields; } private  CrudUtil(); static String buildCreateMessage(final BaseEntity obj); static List<String> getUpdatedFields(final BaseEntity oldObject,
			final BaseEntity newObject); static String convertAuditableFieldsToJson(BaseEntity obj); @SuppressWarnings({ "rawtypes", "unchecked" }) static String buildUpdateMessage(final BaseEntity oldObject,
			final BaseEntity newObject); static String buildDeleteMessage(final BaseEntity obj); static Map<String, Object> buildMapValues(final BaseEntity object); @SuppressWarnings("rawtypes") static Map<String, Object> buildMapValues(final BaseEntity object,
			final List<String> fields); static String buildURLParameters(final BaseEntity object); @SuppressWarnings("rawtypes") static String buildJpaQueryString(final BaseEntity example,
			final boolean exactMatch); @SuppressWarnings("rawtypes") static Object retrieveObjectValue(final Object obj,
			final String property); static Object retrieveNullableObjectValue(final Object obj,
			final String property); static Class<?> retrieveObjectType(final Object obj,
			final String property); static Boolean evaluateExpression(final Object obj,
			final String expression); @SuppressWarnings("unchecked") static String replaceSQLParameters(String sql, final Object obj); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Field> getAllFields(final Class clazz,
			final boolean includeParent); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz); @SuppressWarnings({ "rawtypes" }) static List<Method> getAllMethods(final Class clazz,
			final boolean includeParent); static List<MessageResponse> convertErrorMessage(
			final BindingResult bindingResult, final Locale locale,
			final MessageSource messageSource); static List<MessageResponse> buildSuccessMessage(
			final BaseEntity object, final String code, final Locale locale,
			final MessageSource messageSource); static boolean isCollection(final Object ob); static BaseEntity clone(final BaseEntity source);  }