class IntegerToEnumTypeMapper<T extends Enum<T>>
    implements TypeMapper<Integer, T> {

    private final AtomicReference<T[]> cachedConstants;

    @Inject public Injector injector;

    public IntegerToEnumTypeMapper() {
        cachedConstants = new AtomicReference<>();
    }

    @Override
    public String getLabel() {
        return "Integer to Enum";
    }

    @Override
    public boolean isToolApplicable() {
        return false;
    }

    @Override
    public Type getJavaType(Column column) {
        requireNonNull(injector,
            IntegerToEnumTypeMapper.class.getSimpleName() +
                ".getJavaType(Column) is not available if instantiated " +
                "without injector."
        );

        return new GeneratedEnumType(
            EnumGeneratorUtil.enumNameOf(column, injector),
            EnumGeneratorUtil.enumConstantsOf(column)
        );
    }

    @Override
    public TypeMapper.Category getJavaTypeCategory(Column column) {
        return Category.ENUM;
    }

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

            }
            return cachedConstants.get()[value];
        }
    }

    private T[] constants(Column column, Class<?> entityType) {
        final Class<?> enumClass = classesIn(entityType)
            // Include only enum subclasses
            .filter(Enum.class::isAssignableFrom)

            // Include only enums with the correct name
            .filter(c -> c.getSimpleName().equalsIgnoreCase(
                column.getJavaName().replace("_", "")
            ))

            // Return it as the enumClass or throw an exception.
            .findAny()
            .orElseThrow(() -> new NoSuchElementException("Unable to find Enum class because entity " + entityType.getSimpleName() + " has no enum value for column " + column.getId()));

        final Method values;
        try {
            values = enumClass.getMethod("values");
        } catch (final NoSuchMethodException ex) {
            throw new IllegalArgumentException("Could not find 'values()'-method in enum class '" + enumClass.getName() + "'.", ex);
        }

        try {
            @SuppressWarnings("unchecked") final T[] result = (T[]) values.invoke(null);
            return result;
        } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
            throw new IllegalArgumentException("Error executing 'values()' in generated enum class '" + enumClass.getName() + "'.", ex);
        }
    }

    @Override
    public Integer toDatabaseType(T constant) {<FILL_FUNCTION_BODY>}
}

        if (constant == null) {
            return null;
        } else {
            final Class<?> enumClass = constant.getClass();

            final Method ordinal;
            try {
                ordinal = enumClass.getMethod("ordinal");
            } catch (final NoSuchMethodException ex) {
                throw new IllegalArgumentException("Could not find generated 'ordinal()'-method in enum class '" + constant.getClass().getName() + "'.", ex);
            }

            try {
                @SuppressWarnings("unchecked") final Integer result = (Integer) ordinal.invoke(constant);
                return result;
            } catch (final IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
                throw new IllegalArgumentException("Error executing 'ordinal()' in generated enum class '" + constant.getClass().getName() + "'.", ex);
            }
        }
    
<no_super_class>