### Question:
ReflectionUtil { static public <E extends PMMLObject> void copyState(E from, E to){ Class<?> fromClazz = from.getClass(); Class<?> toClazz = to.getClass(); if(!(fromClazz).isAssignableFrom(toClazz)){ throw new IllegalArgumentException(); } List<Field> fields = getFields(fromClazz); for(Field field : fields){ Object value = getFieldValue(field, from); setFieldValue(field, to, value); } } private  ReflectionUtil(); static boolean equals(Object left, Object right); static boolean equals(PMMLObject left, PMMLObject right); static void copyState(E from, E to); static Field getField(Class<?> clazz, String name); static List<Field> getFields(Class<?> clazz); static List<Field> getAttributeFields(); static List<Field> getElementFields(); static Method getGetterMethod(Field field); static Map<Field, Method> getGetterMethods(Class<?> clazz); @SuppressWarnings ( value = {"unchecked"} ) static E getFieldValue(Field field, Object object); static void setFieldValue(Field field, Object object, Object value); @SuppressWarnings ( value = {"unchecked"} ) static E getGetterMethodValue(Method method, Object object); static boolean isPrimitiveWrapper(Class<?> clazz); static boolean isDefaultValue(Object value); static List<Field> getClassConstants(List<Class<?>> clazzes);  }### Answer:
@Test public void copyState(){ PMML pmml = new PMML(Version.PMML_4_4.getVersion(), new Header(), new DataDictionary()); pmml.getModels(); CustomPMML customPmml = new CustomPMML(); ReflectionUtil.copyState(pmml, customPmml); assertSame(pmml.getVersion(), customPmml.getVersion()); assertSame(pmml.getHeader(), customPmml.getHeader()); assertSame(pmml.getDataDictionary(), customPmml.getDataDictionary()); assertFalse(pmml.hasModels()); assertFalse(customPmml.hasModels()); pmml.addModels(new RegressionModel()); assertTrue(pmml.hasModels()); assertTrue(customPmml.hasModels()); assertSame(pmml.getModels(), customPmml.getModels()); try { ReflectionUtil.copyState(customPmml, pmml); fail(); } catch(IllegalArgumentException iae){ } }