@Test void testWhenConvertUnknownFieldThenFallbackToDefault() { TestEnumV1 converted = underTest.convertToEntityAttribute("FIELD_NOT_EXISTING"); assertEquals(TestEnumV1.FIELD_LAST, converted); }
@Override public E convertToEntityAttribute(String attribute) { try { if (attribute == null) { return null; } return (E) Enum.valueOf(getDefault().getClass(), attribute); } catch (Exception e) { LOGGER.info("The {} value is not backward compatible: {}", getDefault().getClass().getSimpleName(), attribute); } Optional<E> convertedEnum = tryConvertUnknownField(attribute); return convertedEnum.orElse(getDefault()); }
DefaultEnumConverter implements AttributeConverter<E, String> { @Override public E convertToEntityAttribute(String attribute) { try { if (attribute == null) { return null; } return (E) Enum.valueOf(getDefault().getClass(), attribute); } catch (Exception e) { LOGGER.info("The {} value is not backward compatible: {}", getDefault().getClass().getSimpleName(), attribute); } Optional<E> convertedEnum = tryConvertUnknownField(attribute); return convertedEnum.orElse(getDefault()); } }
DefaultEnumConverter implements AttributeConverter<E, String> { @Override public E convertToEntityAttribute(String attribute) { try { if (attribute == null) { return null; } return (E) Enum.valueOf(getDefault().getClass(), attribute); } catch (Exception e) { LOGGER.info("The {} value is not backward compatible: {}", getDefault().getClass().getSimpleName(), attribute); } Optional<E> convertedEnum = tryConvertUnknownField(attribute); return convertedEnum.orElse(getDefault()); }  }
DefaultEnumConverter implements AttributeConverter<E, String> { @Override public E convertToEntityAttribute(String attribute) { try { if (attribute == null) { return null; } return (E) Enum.valueOf(getDefault().getClass(), attribute); } catch (Exception e) { LOGGER.info("The {} value is not backward compatible: {}", getDefault().getClass().getSimpleName(), attribute); } Optional<E> convertedEnum = tryConvertUnknownField(attribute); return convertedEnum.orElse(getDefault()); }  @Override String convertToDatabaseColumn(E attribute); @Override E convertToEntityAttribute(String attribute); abstract E getDefault(); }
DefaultEnumConverter implements AttributeConverter<E, String> { @Override public E convertToEntityAttribute(String attribute) { try { if (attribute == null) { return null; } return (E) Enum.valueOf(getDefault().getClass(), attribute); } catch (Exception e) { LOGGER.info("The {} value is not backward compatible: {}", getDefault().getClass().getSimpleName(), attribute); } Optional<E> convertedEnum = tryConvertUnknownField(attribute); return convertedEnum.orElse(getDefault()); }  @Override String convertToDatabaseColumn(E attribute); @Override E convertToEntityAttribute(String attribute); abstract E getDefault();  }