class SpeedConverter {

    @SuppressWarnings({ "rawtypes", "unchecked" })
    static double toKnots(double speed, String uom) {
        Utilities.ensureNonNull("uom", uom);
        if (LOGGER.isLoggable(Level.FINE)) {
            LOGGER.fine("Convert speed: " + speed + " (" + uom + ")");
        }

        // checks
        if (Double.isNaN(speed)) {
            return Double.NaN;
        }
        if (Double.isInfinite(speed)) {
            throw new IllegalArgumentException("Provided infinite speed, which is illegal!");
        }

        // most common cases first
        if (uom.equalsIgnoreCase(KNOTS) || uom.equalsIgnoreCase(KTS) || uom.equalsIgnoreCase(KN)) {
            return speed;
        }
        if (uom.equalsIgnoreCase(METER_PER_SECOND)) {
            return (speed * METERS_PER_SECOND_TO_KNOTS);
        }
        if (uom.equalsIgnoreCase(CENTIMETER_PER_SECOND)) {
            return (speed * CENTIMETERS_PER_SECOND_TO_KNOTS);
        }
        if (uom.equalsIgnoreCase(KILOMETER_PER_HOUR)) {
            return (speed * KILOMETERS_PER_HOUR_TO_KNOTS);
        }
        if (uom.equalsIgnoreCase(MILE_PER_HOUR)) {
            return (speed * MILES_PER_HOUR_TO_KNOTS);
        }

        // ok let's try harder --> this is going to be slower
        try {
            Unit unit = (Unit) SpeedConverter.UCUM_FORMAT_INSTANCE.parseObject(uom);
            UnitConverter converter = unit.getConverterTo(NonSI.KNOT);
            return converter.convert(speed);
        } catch (Exception e) {
            throw new IllegalArgumentException("The supplied units isn't currently supported:"
                    + uom, e);
        }
    }

}