@Override
    public T toJavaType(Column column, Class<?> entityType, String value) {
        if (value == null) {
            return null;
        } else {
            if (cachedEnum.get() == null) {
                synchronized (cachedEnum) {
                    if (cachedEnum.get() == null) {
                        cachedEnum.set(enumClass(column, entityType));
                    }
                }
            }
            final Class<?> enumClass = cachedEnum.get();

            final Method fromDatabase;
            try {
                fromDatabase = enumClass.getMethod(FROM_DATABASE_METHOD, String.class);
            } catch (final NoSuchMethodException ex) {
                // This cannot happen because we ensure that this method actually do exist above.
                throw new IllegalArgumentException("Could not find generated '" + FROM_DATABASE_METHOD + "'-method in enum class '" + enumClass.getName() + "'.", ex);
            }

            try {
                @SuppressWarnings("unchecked")
                final T result = (T) fromDatabase.invoke(null, value);
                return result;
            } catch (final IllegalAccessException 
                         | IllegalArgumentException 
                         | InvocationTargetException ex) {
                throw new IllegalArgumentException(
                    "Error executing '" + FROM_DATABASE_METHOD + 
                    "' in generated enum class '" + enumClass.getName() + "'.",
                    ex
                );
            }
        }
    }
@param <T>  the enum type

@author  Emil Forslund
@author  Simon Jonasson
@since   3.0.0
plugin-parent/enum-generator/src/main/java/com/speedment/plugins/enums/StringToEnumTypeMapper.java