jakartaee / jakartaee/jsonp-api

Offer Abstract Delegators

Open
#153 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
160
Forks
64
Avg merge
4d 5h
Merged PRs (30d)
4

Description

The **API** should offer abstract implementations for both ``JsonObject`` and ``JsonArray``. These implementations will encapsluate a ``JsonObject`` and ``JsonArray`` delegator respectively , in order to leverage polymorphism.

E.g.

```java
public abstract class AbstractJsonObject implements JsonObject {
private final JsonObject delegate;

public AbstractJsonObject (final JsonObject delegate) {
this.delegate = delegate;
}

@Override
public final JsonArray getJsonArray(final String name) {
return this.delegate.getJsonArray(name);
}
//all other implementations, all delegated
}
```

Here are some examples of usage (object orientation):

Polymorphic entity: https://github.com/amihaiemil/docker-java-api/blob/master/src/main/java/com/amihaiemil/docker/RtImage.java (extends JsonResource which is the same concept).

2 Articles:

https://www.amihaiemil.com/2017/10/16/javaee8-jsoncollectors-oop-alternative.html
https://www.amihaiemil.com/2017/06/14/non-flushable-jsonobjectbuilder.html (this is for JsonObjectBuilder)

This should be an API addition, obviously, since these classes are provider-agnostic, they are abstract and do not care about any concrete implementation.

If this is wanted, I'll make a PR myself.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the JsonObject and JsonArray interfaces, then compare the linked RtImage example and its JsonResource base class for the intended delegation pattern. Done means the API offers provider-agnostic abstract delegators for both interfaces, with the interface operations delegated consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.