Skip to content

Helidon 4.0-M2 #155

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

Merged
merged 5 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: [20]
java_version: [21-ea]
os: [ubuntu-latest]

steps:
Expand Down
11 changes: 9 additions & 2 deletions jsonb-generator/src/main/java/io/avaje/jsonb/generator/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static String shortName(String fullType) {
}

static String shortType(String fullType) {
int p = fullType.lastIndexOf('.');
final int p = fullType.lastIndexOf('.');
if (p == -1) {
return fullType;
} else if (fullType.startsWith("java")) {
Expand All @@ -47,11 +47,18 @@ static String shortType(String fullType) {
var result = "";
var foundClass = false;
for (final String part : fullType.split("\\.")) {
if (foundClass || Character.isUpperCase(part.charAt(0))) {
char firstChar = part.charAt(0);
if (foundClass
|| Character.isUpperCase(firstChar)
|| (!Character.isAlphabetic(firstChar) && Character.isJavaIdentifierStart(firstChar))) {
foundClass = true;
result += (result.isEmpty() ? "" : ".") + part;
}
}
// when in doubt, do the basic thing
if (result.isBlank()) {
return fullType.substring(p + 1);
}
return result;
}
}
Expand Down
6 changes: 3 additions & 3 deletions jsonb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</dependency>

<dependency>
<groupId>io.helidon.nima.webserver</groupId>
<artifactId>helidon-nima-webserver</artifactId>
<version>4.0.0-M1</version>
<groupId>io.helidon.webserver</groupId>
<artifactId>helidon-webserver</artifactId>
<version>4.0.0-M2</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
Expand Down
33 changes: 19 additions & 14 deletions jsonb/src/main/java/io/avaje/jsonb/Json.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package io.avaje.jsonb;


import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.MODULE;
import static java.lang.annotation.ElementType.PACKAGE;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.CLASS;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
Expand All @@ -30,7 +35,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target(ElementType.TYPE)
@Target(TYPE)
public @interface Json {

/**
Expand Down Expand Up @@ -69,7 +74,7 @@
*/
@Retention(CLASS)
@Repeatable(List.class)
@Target({ElementType.TYPE, ElementType.PACKAGE, ElementType.MODULE})
@Target({TYPE, PACKAGE, MODULE})
@interface Import {

/** Specify types to generate Json Adapters for. */
Expand All @@ -87,7 +92,7 @@
Class<?> implementation() default Void.class;

@Retention(CLASS)
@Target({ElementType.TYPE, ElementType.PACKAGE, ElementType.MODULE})
@Target({TYPE, PACKAGE, MODULE})
@interface List {

Import[] value();
Expand All @@ -105,7 +110,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface Property {

/**
Expand All @@ -125,7 +130,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface Alias {

/** One or more secondary names to accept as aliases to the official name. */
Expand All @@ -137,7 +142,7 @@
*/
@Deprecated
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface JsonAlias {

/** One or more secondary names to accept as aliases to the official name. */
Expand All @@ -155,7 +160,7 @@
* serialization but not deserialization.
*/
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface Ignore {

/**
Expand Down Expand Up @@ -183,7 +188,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface Unmapped {

}
Expand Down Expand Up @@ -217,7 +222,7 @@
* }</pre>
*/
@Retention(RUNTIME)
@Target({ElementType.METHOD})
@Target(METHOD)
@interface Value {
}

Expand All @@ -241,7 +246,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target({ElementType.TYPE})
@Target(TYPE)
@Repeatable(SubTypes.class)
@interface SubType {

Expand All @@ -263,7 +268,7 @@
* type can be represented as.
*/
@Retention(CLASS)
@Target({ElementType.TYPE})
@Target(TYPE)
@interface SubTypes {

SubType[] value();
Expand All @@ -273,7 +278,7 @@
* Marks a String field as containing raw JSON content.
*/
@Retention(CLASS)
@Target({ElementType.FIELD})
@Target(FIELD)
@interface Raw {

}
Expand All @@ -298,7 +303,7 @@
* }</pre>
*/
@Retention(CLASS)
@Target({ElementType.TYPE})
@Target(TYPE)
@interface MixIn {
/** The concrete type to mix. */
Class<?> value();
Expand Down
2 changes: 1 addition & 1 deletion jsonb/src/main/java/io/avaje/jsonb/stream/JsonOutput.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.avaje.jsonb.stream;

import io.helidon.nima.webserver.http.ServerResponse;
import io.helidon.webserver.http.ServerResponse;

import java.io.Closeable;
import java.io.IOException;
Expand Down
8 changes: 5 additions & 3 deletions jsonb/src/main/java/io/avaje/jsonb/stream/NimaJsonOutput.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.avaje.jsonb.stream;

import io.helidon.common.http.Http;
import io.helidon.nima.webserver.http.ServerResponse;
import io.helidon.http.Http;
import io.helidon.webserver.http.ServerResponse;

import java.io.IOException;
import java.io.OutputStream;

final class NimaJsonOutput implements JsonOutput {

private static final String CHUNKED = "chunked";

private final ServerResponse res;
private OutputStream os;
private boolean fixedLength;
Expand All @@ -20,7 +22,7 @@ private OutputStream os() {
if (os == null) {
if (!fixedLength) {
// going to use chunked content
res.header(Http.HeaderValues.TRANSFER_ENCODING_CHUNKED);
res.header(Http.HeaderNames.TRANSFER_ENCODING, CHUNKED);
}
os = res.outputStream();
}
Expand Down
2 changes: 1 addition & 1 deletion jsonb/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
uses io.avaje.jsonb.JsonbComponent;
uses io.avaje.jsonb.Jsonb.GeneratedComponent;

requires static io.helidon.nima.webserver;
requires static io.helidon.webserver;

}