jakartaee / jakartaee/jsonb-api

Add support for EnumMap and EnumSet

Open
#186 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
95
Forks
41
Avg merge
1d 6h
Merged PRs (30d)
35

Description

The classes [`java.util.EnumSet`](https://docs.oracle.com/javase/8/docs/api/java/util/EnumSet.html) and [`java.util.EnumMap`](https://docs.oracle.com/javase/8/docs/api/java/util/EnumMap.html) 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.

Contributor guide

Open the contributing guide

Research direction

Start with JSON-B's existing collection support and the java.util.EnumSet and java.util.EnumMap contracts linked in the issue. Resolve whether the scope is limited to these types or includes general stringable keys, then define completion around JSON-B serialization and deserialization behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.