@Test public void updateObject() throws InvocationTargetException, IllegalAccessException { StringFieldMetadata toMerge = new StringFieldMetadata(); FieldMetadataUtils.updateObject(MetadataConstants.DEFAULT_STRING_META, toMerge); LOGGER.info("{}", toMerge); }
public static <T extends FieldMetadata> void updateObject(T from, T to) throws IllegalStateException { Validate.notNull(from); Validate.notNull(to); if(to == from) { return; } Class<?> originalClass = to.getClass(); Class<?> updateClass = from.getClass(); if(!originalClass.equals(updateClass)) { throw new IllegalArgumentException("Received objects are not the same type of class"); } List<PropertyDescriptor> descriptors = getDescriptors(originalClass); for(PropertyDescriptor descriptor : descriptors) { updateProperty(to, from, descriptor); } }
FieldMetadataUtils { public static <T extends FieldMetadata> void updateObject(T from, T to) throws IllegalStateException { Validate.notNull(from); Validate.notNull(to); if(to == from) { return; } Class<?> originalClass = to.getClass(); Class<?> updateClass = from.getClass(); if(!originalClass.equals(updateClass)) { throw new IllegalArgumentException("Received objects are not the same type of class"); } List<PropertyDescriptor> descriptors = getDescriptors(originalClass); for(PropertyDescriptor descriptor : descriptors) { updateProperty(to, from, descriptor); } } }
FieldMetadataUtils { public static <T extends FieldMetadata> void updateObject(T from, T to) throws IllegalStateException { Validate.notNull(from); Validate.notNull(to); if(to == from) { return; } Class<?> originalClass = to.getClass(); Class<?> updateClass = from.getClass(); if(!originalClass.equals(updateClass)) { throw new IllegalArgumentException("Received objects are not the same type of class"); } List<PropertyDescriptor> descriptors = getDescriptors(originalClass); for(PropertyDescriptor descriptor : descriptors) { updateProperty(to, from, descriptor); } } private  FieldMetadataUtils(); }
FieldMetadataUtils { public static <T extends FieldMetadata> void updateObject(T from, T to) throws IllegalStateException { Validate.notNull(from); Validate.notNull(to); if(to == from) { return; } Class<?> originalClass = to.getClass(); Class<?> updateClass = from.getClass(); if(!originalClass.equals(updateClass)) { throw new IllegalArgumentException("Received objects are not the same type of class"); } List<PropertyDescriptor> descriptors = getDescriptors(originalClass); for(PropertyDescriptor descriptor : descriptors) { updateProperty(to, from, descriptor); } } private  FieldMetadataUtils(); @SuppressWarnings("unchecked") static T diff(T from, T to); @SuppressWarnings("unchecked") static T merge(T from, T to); static void updateObject(T from, T to); }
FieldMetadataUtils { public static <T extends FieldMetadata> void updateObject(T from, T to) throws IllegalStateException { Validate.notNull(from); Validate.notNull(to); if(to == from) { return; } Class<?> originalClass = to.getClass(); Class<?> updateClass = from.getClass(); if(!originalClass.equals(updateClass)) { throw new IllegalArgumentException("Received objects are not the same type of class"); } List<PropertyDescriptor> descriptors = getDescriptors(originalClass); for(PropertyDescriptor descriptor : descriptors) { updateProperty(to, from, descriptor); } } private  FieldMetadataUtils(); @SuppressWarnings("unchecked") static T diff(T from, T to); @SuppressWarnings("unchecked") static T merge(T from, T to); static void updateObject(T from, T to);  }