@Test public void diffObject() throws InvocationTargetException, IllegalAccessException { ObjectTypeMetadata defaultMeta = MetadataConstants.DEFAULT_OBJECT_META; ObjectTypeMetadata field = new ObjectTypeMetadata("obj", Arrays.asList(MetadataConstants.DEFAULT_STRING_META)); ObjectTypeMetadata diff = FieldMetadataUtils.diff(field, defaultMeta); assertEquals(diff.getInnerMetadata().size(), 1); }
@SuppressWarnings("unchecked") public static <T extends FieldMetadata> T diff(T from, T to) throws IllegalStateException { try { T empty = (T) invokeConstructor(from.getClass()); List<PropertyDescriptor> descriptors = getDescriptors(from.getClass()); for(PropertyDescriptor descriptor : descriptors) { diffProperty(empty, to, from, descriptor); } return empty; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException ex) { throw new IllegalStateException("Failed to diff bean", ex); } }
FieldMetadataUtils { @SuppressWarnings("unchecked") public static <T extends FieldMetadata> T diff(T from, T to) throws IllegalStateException { try { T empty = (T) invokeConstructor(from.getClass()); List<PropertyDescriptor> descriptors = getDescriptors(from.getClass()); for(PropertyDescriptor descriptor : descriptors) { diffProperty(empty, to, from, descriptor); } return empty; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException ex) { throw new IllegalStateException("Failed to diff bean", ex); } } }
FieldMetadataUtils { @SuppressWarnings("unchecked") public static <T extends FieldMetadata> T diff(T from, T to) throws IllegalStateException { try { T empty = (T) invokeConstructor(from.getClass()); List<PropertyDescriptor> descriptors = getDescriptors(from.getClass()); for(PropertyDescriptor descriptor : descriptors) { diffProperty(empty, to, from, descriptor); } return empty; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException ex) { throw new IllegalStateException("Failed to diff bean", ex); } } private  FieldMetadataUtils(); }
FieldMetadataUtils { @SuppressWarnings("unchecked") public static <T extends FieldMetadata> T diff(T from, T to) throws IllegalStateException { try { T empty = (T) invokeConstructor(from.getClass()); List<PropertyDescriptor> descriptors = getDescriptors(from.getClass()); for(PropertyDescriptor descriptor : descriptors) { diffProperty(empty, to, from, descriptor); } return empty; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException ex) { throw new IllegalStateException("Failed to diff bean", ex); } } 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 { @SuppressWarnings("unchecked") public static <T extends FieldMetadata> T diff(T from, T to) throws IllegalStateException { try { T empty = (T) invokeConstructor(from.getClass()); List<PropertyDescriptor> descriptors = getDescriptors(from.getClass()); for(PropertyDescriptor descriptor : descriptors) { diffProperty(empty, to, from, descriptor); } return empty; } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException ex) { throw new IllegalStateException("Failed to diff bean", ex); } } 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);  }