/** * Returns the numeric value of the coordinate operation parameter in the specified unit of * measure. This convenience method apply unit conversion on the fly as needed. * * @param unit The unit of measure for the value to be returned. * @return The numeric value represented by this parameter after conversion to type {@code * double} and conversion to {@code unit}. * @throws IllegalArgumentException if the specified unit is invalid for this parameter. */ public double doubleValue(final Unit<?> unit) throws IllegalArgumentException { ensureNonNull("unit", unit); final Unit<?> thisUnit = getUnit(); if (thisUnit == null) { throw unitlessParameter(descriptor); } final int expectedID = Parameter.getUnitMessageID(thisUnit); if (Parameter.getUnitMessageID(unit) != expectedID) { throw new IllegalArgumentException(Errors.format(expectedID, unit)); } return Units.getConverterToAny(thisUnit, unit).convert(value); }