Skip to content

Add support for EnumMap and EnumSet #186

Description

@aguibert

The classes java.util.EnumSet and java.util.EnumMap are part of the JDK and could be supported by JSON-B.

EnumSet should certainly be supported because JSON-B already support collections of POJOs, and EnumSet only doesn't work because it doesn't have any standard constructors.

EnumMap could also be considered. Technically JSON-B currently only supports java.lang.String keys, but Enums are quite easy to translate to/from String values. This could also potentially expand into a larger effort to support "stringable" keys as defined by Section 3.2 of the JAX-RS 2.1 spec:

Valid parameter types for each of the above annotations are listed in the corresponding Javadoc, however in general (excluding @Context) the following types are supported:

  1. Types for which a ParamConverter is available via a registered ParamConverterProvider. See Javadoc for these classes for more information.
  2. Primitive types.
  3. Types that have a constructor that accepts a single String argument.
  4. Types that have a static method named valueOf or fromString with a single String argument that return an instance of the type. If both methods are present then valueOf MUST be used unless the type is an enum in which case fromString MUST be used1.
  5. List, Set, or SortedSet, where T satisfies 1, 3 or 4 above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions