/** * Returns the unit derived from this unit using the specified converter. The converter does not * need to be linear. For example:[code] Unit<Dimensionless> DECIBEL = Unit.ONE.transform( new * LogConverter(10).inverse().concatenate( new RationalConverter(1, 10))); [/code] * * @param operation the converter from the transformed unit to this unit. * @return the unit after the specified transformation. */ @SuppressWarnings("unchecked") public final Unit<IMoney> transform(UnitConverter operation) { if (this instanceof Unit<?>) { Unit<IMoney> tf = this; Unit<?> parent = (Unit<?>) ((TransformedUnit<?>) tf).getParentUnit(); UnitConverter toParent = ((TransformedUnit<?>) tf).toParentUnit(); if (toParent == null) return (Unit<IMoney>) parent; UnitConverter toParentConcat = toParent.concatenate(operation); if (toParentConcat == AbstractConverter.IDENTITY) return (Unit<IMoney>) parent; return new TransformedUnit<IMoney>((Unit<IMoney>) parent, (AbstractConverter) toParentConcat); } if (operation == AbstractConverter.IDENTITY) return this; return new TransformedUnit<IMoney>(this, (AbstractConverter) operation); }