/** * Return the DataType corresponding to a given Java type. For example 'text' is returned given * String.class. * * @param clazz The class to look up. * @return The associated class or null if not found. */ @Nullable public static DataType getDataType(Class<?> clazz) { /* * This has to be done just-in-time as the javaToDataType is static and * can't be loaded as the enum is created. */ if (javaToDataType.isEmpty()) { for (final DataType dataType : DataType.values()) { javaToDataType.put(dataType.javaClass, dataType); } } return javaToDataType.get(clazz); }