@Nonnull public static String doConversion(@Nonnull UnitConverter<String> converter, @Nullable String from, @Nonnull UnitType<String> fromUnitType, @Nonnull UnitType<String> toUnitType) throws ConversionException { final String result; if (Strings.isEmpty(from)) { result = ""; } else { final String to; try { if (converter.isSupported(fromUnitType, toUnitType)) { to = converter.convert(UnitImpl.newInstance(from, fromUnitType), toUnitType).getValue(); } else { to = ""; } } catch (RuntimeException e) { throw new ConversionException(e); } result = to; } return result; } }