/** * Returns a clone of this unit format. The new unit format will be initialized to the same * {@linkplain #getLocale() locale} and {@linkplain #label(Unit, String) labels} than this format. * * @return a clone of this unit format. */ @Override public UnitFormat clone() { final UnitFormat f = (UnitFormat) super.clone(); try { AccessController.doPrivileged(new FinalFieldSetter<>(UnitFormat.class, "unitToLabel", "labelToUnit")) .set(f, clone(unitToLabel), clone(labelToUnit)); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.cloneFailure(e); } return f; }
/** * Returns a clone of this range format. * * @return a clone of this range format. */ @Override public RangeFormat clone() { final RangeFormat f = (RangeFormat) super.clone(); try { AccessController.doPrivileged(new FinalFieldSetter<>(RangeFormat.class, "elementFormat", "unitFormat")) .set(f, elementFormat.clone(), unitFormat.clone()); } catch (ReflectiveOperationException e) { throw FinalFieldSetter.cloneFailure(e); } return f; } }