/** * Create a deep copy (copy receiver and copy properties). * * @param <T> * @return new T instance */ public <T extends FeaturesCapable> T copy() { try { @SuppressWarnings("unchecked") final T self = (T) clone(); copyInto(self); return self; } catch (CloneNotSupportedException e) { throw new IllegalStateException("cannot clone() " + this, e); } }
/** * {@inheritDoc} */ @Override protected void copyInto(FeaturesCapable target) { super.copyInto(target); final MetaBean copy = (MetaBean) target; if (properties != null) { copy.properties = new TreeMap<String, MetaProperty>(); for (Map.Entry<String, MetaProperty> entry : properties.entrySet()) { copy.properties.put(entry.getKey(), (MetaProperty) entry.getValue().copy()); } } }