Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand @Value to Inline regular classes #220

Merged
merged 55 commits into from
Mar 15, 2024
Merged

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Mar 9, 2024

Now can inline classes with @value

fixes #210
also part of #216

now we can have a class like:

public record Inlined(@Json.Value int value, String discarded) {
  public Inlined(int value) {
    this(value, "idk");
  }
}

and a simple adapter will be generated

@Generated("avaje-jsonb-generator:1.11-RC2")
public final class InlinedJsonAdapter implements JsonAdapter<Inlined> {

  private final JsonAdapter<Integer> adapter;

  public InlinedJsonAdapter(Jsonb jsonb) {
    this.adapter = jsonb.adapter(Integer.TYPE);
  }

  @Override
  public void toJson(JsonWriter writer, Inlined value) {
    adapter.toJson(writer, value.value());
  }

  @Override
  public Inlined fromJson(JsonReader reader) {
    return new Inlined(adapter.fromJson(reader));
  }
}

People shouldn't use it, but the reality is that this is still used all over the place
@SentryMan SentryMan requested a review from rbygrave March 9, 2024 00:54
@SentryMan SentryMan self-assigned this Mar 9, 2024
@SentryMan SentryMan added the enhancement New feature or request label Mar 9, 2024
@SentryMan SentryMan added this to the 1.11 milestone Mar 9, 2024
@SentryMan SentryMan enabled auto-merge March 9, 2024 00:59
dependabot bot and others added 11 commits March 8, 2024 20:01
Bumps io.helidon.webserver:helidon-webserver from 4.0.4 to 4.0.5.

---
updated-dependencies:
- dependency-name: io.helidon.webserver:helidon-webserver
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps io.avaje:junit from 1.3 to 1.4.

---
updated-dependencies:
- dependency-name: io.avaje:junit
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [io.avaje:avaje-inject](https://github.com/avaje/avaje-inject) from 9.10 to 9.11.
- [Release notes](https://github.com/avaje/avaje-inject/releases)
- [Commits](avaje/avaje-inject@9.10...9.11)

---
updated-dependencies:
- dependency-name: io.avaje:avaje-inject
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [org.springframework.boot:spring-boot-dependencies](https://github.com/spring-projects/spring-boot) from 3.2.2 to 3.2.3.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](spring-projects/spring-boot@v3.2.2...v3.2.3)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-dependencies
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
@rbygrave rbygrave disabled auto-merge March 15, 2024 09:41
@rbygrave rbygrave merged commit 53ed43a into avaje:main Mar 15, 2024
2 checks passed
@SentryMan SentryMan deleted the inline branch March 15, 2024 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support inline objects with a single field
2 participants