@Test public void testFinalAttributes() { H h = new H(); h.c = "c2"; assertEquals("c2", Cloner.shallowCopy(h).c); }
@SuppressWarnings("unchecked") public static <T> T shallowCopy(T original) { Class<? extends T> clazz = (Class<? extends T>) original.getClass(); BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz); if (beanClass == null) { beanClass = BeanClass.buildFrom(clazz); classes.put(clazz, beanClass); } return shallowCopyHelper(original, beanClass); }
Cloner { @SuppressWarnings("unchecked") public static <T> T shallowCopy(T original) { Class<? extends T> clazz = (Class<? extends T>) original.getClass(); BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz); if (beanClass == null) { beanClass = BeanClass.buildFrom(clazz); classes.put(clazz, beanClass); } return shallowCopyHelper(original, beanClass); } }
Cloner { @SuppressWarnings("unchecked") public static <T> T shallowCopy(T original) { Class<? extends T> clazz = (Class<? extends T>) original.getClass(); BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz); if (beanClass == null) { beanClass = BeanClass.buildFrom(clazz); classes.put(clazz, beanClass); } return shallowCopyHelper(original, beanClass); }  }
Cloner { @SuppressWarnings("unchecked") public static <T> T shallowCopy(T original) { Class<? extends T> clazz = (Class<? extends T>) original.getClass(); BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz); if (beanClass == null) { beanClass = BeanClass.buildFrom(clazz); classes.put(clazz, beanClass); } return shallowCopyHelper(original, beanClass); }  @SuppressWarnings("unchecked") static T shallowCopy(T original); }
Cloner { @SuppressWarnings("unchecked") public static <T> T shallowCopy(T original) { Class<? extends T> clazz = (Class<? extends T>) original.getClass(); BeanClass<? extends T> beanClass = (BeanClass<? extends T>) classes.get(clazz); if (beanClass == null) { beanClass = BeanClass.buildFrom(clazz); classes.put(clazz, beanClass); } return shallowCopyHelper(original, beanClass); }  @SuppressWarnings("unchecked") static T shallowCopy(T original);  }