class UnitUtils {

    public static @Nullable String getDimensionName(Unit<?> unit) {
        for (Class<? extends SystemOfUnits> system : ALL_SYSTEM_OF_UNITS) {
            for (Field field : system.getDeclaredFields()) {
                if (field.getType().isAssignableFrom(Unit.class) && Modifier.isStatic(field.getModifiers())) {
                    Type genericType = field.getGenericType();
                    if (genericType instanceof ParameterizedType) {
                        String dimension = ((Class<?>) ((ParameterizedType) genericType).getActualTypeArguments()[0])
                                .getSimpleName();
                        Unit<?> systemUnit;
                        try {
                            systemUnit = (Unit<?>) field.get(null);
                            if (systemUnit == null) {
                                LOGGER.warn("Unit field points to a null value: {}", field);
                            } else if (systemUnit.isCompatible(unit)) {
                                return dimension;
                            }
                        } catch (IllegalArgumentException | IllegalAccessException e) {
                            LOGGER.error("The unit field '{}' seems to be not accessible", field, e);
                        }
                    } else {
                        LOGGER.warn("There is a unit field defined which has no generic type parametrization: {}",
                                field);
                    }
                }
            }
        }
        return null;
    }

}