Using Attribute Converters for Enums

public interface EnumAttributeConverter<E extends Enum<E>, Y>
        extends AttributeConverter<E, Y> {

}
@Converter
public class DayOfWeekIntegerConverter
        implements EnumAttributeConverter<DayOfWeek, Integer> {

    @Override
    public Integer convertToDatabaseColumn(final DayOfWeek attribute) {
        return ofNullable(attribute).map(DayOfWeek::getValue).orElse(null);
    }

    @Override
    public DayOfWeek convertToEntityAttribute(final Integer dbData) {
        return ofNullable(dbData).map(DayOfWeek::of).orElse(null);
    }
}