UnitUtils { public static @Nullable Class<? extends Quantity<?>> parseDimension(String dimension) { if (dimension.isBlank()) { return null; } try { return dimensionClass(FRAMEWORK_DIMENSION_PREFIX, dimension); } catch (ClassNotFoundException e1) { try { return dimensionClass(JAVAX_MEASURE_QUANTITY_PREFIX, dimension); } catch (ClassNotFoundException e2) { throw new IllegalArgumentException( "Error creating a dimension Class instance for name '" + dimension + "'."); } } }  static @Nullable Class<? extends Quantity<?>> parseDimension(String dimension); static @Nullable String getDimensionName(Unit<?> unit); static @Nullable Unit<?> parseUnit(@Nullable String pattern); static boolean isDifferentMeasurementSystem(Unit<? extends Quantity<?>> thisUnit, Unit<?> thatUnit); static final String UNIT_PLACEHOLDER; static final String UNIT_PERCENT_FORMAT_STRING; }
@Test public void whenValidDimensionIsGivenShouldCreateQuantityClass() { Class<? extends Quantity<?>> temperature = UnitUtils.parseDimension("Temperature"); assertNotNull(temperature); assertTrue(Temperature.class.isAssignableFrom(temperature)); Class<? extends Quantity<?>> intensity = UnitUtils.parseDimension("Intensity"); assertNotNull(intensity); assertTrue(Intensity.class.isAssignableFrom(intensity)); }