Class CaseInsensitiveHyphenToUnderscoreEnumConverter<T extends Enum<T>>

java.lang.Object
org.tailormap.api.util.CaseInsensitiveHyphenToUnderscoreEnumConverter<T>
Type Parameters:
T - the enum type
All Implemented Interfaces:
org.springframework.core.convert.converter.Converter<String,T>

public class CaseInsensitiveHyphenToUnderscoreEnumConverter<T extends Enum<T>> extends Object implements org.springframework.core.convert.converter.Converter<String,T>
A utility class to convert a string to an enum in a case-insensitive way, replacing hyphens with underscores. Because Angular/TypeScript prefers using eg. "layer-attached-file" instead of "LAYER_ATTACHED_FILE" for enum values, this converter allows for a more user-friendly way to convert strings to enums.
  • Constructor Details

    • CaseInsensitiveHyphenToUnderscoreEnumConverter

      public CaseInsensitiveHyphenToUnderscoreEnumConverter(Class<T> enumClass)
  • Method Details

    • convert

      public T convert(String from)
      Specified by:
      convert in interface org.springframework.core.convert.converter.Converter<String, T extends Enum<T>>