Class AbstractXmlAdapter.EnumIoMapped<T extends java.lang.Enum<T>>

  • Type Parameters:
    T - generic enum class.
    Enclosing class:
    AbstractXmlAdapter

    public static class AbstractXmlAdapter.EnumIoMapped<T extends java.lang.Enum<T>>
    extends AbstractXmlAdapter.EnumIO<T>
    Support for Enum I/O to XML using explicit mapping.

    This converts to and from ordinal numbers so the order of definitions in the enum has to match up with the (former) constant values.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.Class<T> clazz  
      (package private) java.util.Map<T,​java.lang.String> mapFromEnum  
      (package private) java.util.Map<java.lang.String,​T> mapToEnum  
    • Constructor Summary

      Constructors 
      Constructor Description
      EnumIoMapped​(java.lang.Class<T> clazz, java.util.Map<java.lang.String,​T> mapToEnum)  
      EnumIoMapped​(java.lang.Class<T> clazz, java.util.Map<java.lang.String,​T> mapToEnum, java.util.Map<T,​java.lang.String> mapFromEnum)  
    • Field Detail

      • clazz

        final java.lang.Class<T extends java.lang.Enum<T>> clazz
      • mapFromEnum

        final java.util.Map<T extends java.lang.Enum<T>,​java.lang.String> mapFromEnum
      • mapToEnum

        final java.util.Map<java.lang.String,​T extends java.lang.Enum<T>> mapToEnum
    • Constructor Detail

      • EnumIoMapped

        public EnumIoMapped​(@Nonnull
                            java.lang.Class<T> clazz,
                            @Nonnull
                            java.util.Map<java.lang.String,​T> mapToEnum,
                            @Nonnull
                            java.util.Map<T,​java.lang.String> mapFromEnum)
        Parameters:
        clazz - enum class.
        mapToEnum - Substitutes an explicit mapping for mapping from Strings to enums; this could allow e.g. accepting both name and number versions. Multiple entries are OK: this can map both "1" and "Foo" to Foo for past-schema support.
        mapFromEnum - Substitutes an explicit mapping enum entries to Strings; this determines what will be written out.
      • EnumIoMapped

        public EnumIoMapped​(@Nonnull
                            java.lang.Class<T> clazz,
                            @Nonnull
                            java.util.Map<java.lang.String,​T> mapToEnum)
        Parameters:
        clazz - enum class.
        mapToEnum - Substitutes an explicit mapping for mapping from Strings to enums; this could allow e.g. accepting both name and number versions. Multiple entries are OK: this can map both "1" and "Foo" to Foo for past-schema support. The mapping from enums to Strings uses the enum names.