2023-01-21 15:01:54 +01:00
|
|
|
package io.gitlab.jfronny.gson.compile.example;
|
2022-10-31 20:52:48 +01:00
|
|
|
|
2022-11-01 10:08:03 +01:00
|
|
|
import io.gitlab.jfronny.gson.annotations.SerializedName;
|
2022-11-01 15:24:59 +01:00
|
|
|
import io.gitlab.jfronny.gson.compile.annotations.*;
|
2022-11-13 10:59:19 +01:00
|
|
|
import io.gitlab.jfronny.gson.stream.JsonReader;
|
|
|
|
import io.gitlab.jfronny.gson.stream.JsonWriter;
|
2022-10-31 20:52:48 +01:00
|
|
|
|
2022-11-01 15:08:02 +01:00
|
|
|
import java.util.*;
|
|
|
|
|
2022-10-31 20:52:48 +01:00
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
System.out.println("Hello world!");
|
|
|
|
}
|
|
|
|
|
|
|
|
@GSerializable(generateAdapter = true)
|
|
|
|
public static class ExamplePojo {
|
2022-11-01 10:08:03 +01:00
|
|
|
@SerializedName("someBalue")
|
2022-10-31 20:52:48 +01:00
|
|
|
public String someValue;
|
2022-11-01 10:08:03 +01:00
|
|
|
@GComment("Yes!")
|
2022-10-31 20:52:48 +01:00
|
|
|
public Boolean someBool;
|
2022-11-01 10:08:03 +01:00
|
|
|
|
|
|
|
@GComment("Halal")
|
|
|
|
@SerializedName("bingChiller")
|
|
|
|
public String getBass() {
|
|
|
|
return "Yes";
|
|
|
|
}
|
2022-11-01 10:29:09 +01:00
|
|
|
|
|
|
|
public ExamplePojo2 nested;
|
2022-11-01 15:08:02 +01:00
|
|
|
|
|
|
|
public Set<ExamplePojo> recursive1;
|
|
|
|
|
|
|
|
public LinkedList<ExampleRecord> recursive2;
|
|
|
|
|
|
|
|
public Queue<String> queue;
|
|
|
|
|
2022-11-01 16:58:16 +01:00
|
|
|
public Date date;
|
|
|
|
|
2022-11-01 17:26:32 +01:00
|
|
|
public EeE eEe;
|
|
|
|
|
2022-11-01 20:40:53 +01:00
|
|
|
public UnsupportedClass unsupported;
|
|
|
|
|
|
|
|
public String getUnsupported() {
|
|
|
|
return unsupported == null ? null : unsupported.text;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setUnsupported(String text) {
|
|
|
|
unsupported = new UnsupportedClass(text);
|
|
|
|
}
|
|
|
|
|
2022-11-01 15:08:02 +01:00
|
|
|
public void setJoe(String joe) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getJoe() {
|
|
|
|
return "A";
|
|
|
|
}
|
2022-11-01 10:29:09 +01:00
|
|
|
}
|
|
|
|
|
2022-11-13 10:59:19 +01:00
|
|
|
@GSerializable(configure = Configuration.class)
|
2022-11-01 10:29:09 +01:00
|
|
|
public static class ExamplePojo2 {
|
|
|
|
@GComment("Yes!")
|
2023-01-22 14:59:43 +01:00
|
|
|
@GWith(serializer = ExampleAdapter.class)
|
2022-11-01 10:29:09 +01:00
|
|
|
public boolean primitive;
|
2022-11-01 13:48:23 +01:00
|
|
|
public ExamplePojo2[] recursiveTest;
|
2022-11-01 21:29:43 +01:00
|
|
|
|
|
|
|
public Map<EeE, Example4> map1;
|
|
|
|
|
|
|
|
public Map<String, String> map2;
|
|
|
|
|
|
|
|
public Map<Integer, String> map3;
|
|
|
|
|
|
|
|
public Map<UUID, String> map4;
|
2022-11-24 20:35:28 +01:00
|
|
|
|
|
|
|
public Inner inner;
|
|
|
|
|
|
|
|
@GSerializable
|
|
|
|
public record Inner(String s, Inner2 inner2) {
|
|
|
|
@GSerializable
|
|
|
|
public record Inner2(String s) {}
|
|
|
|
}
|
2022-10-31 20:52:48 +01:00
|
|
|
}
|
2022-11-01 11:50:02 +01:00
|
|
|
|
|
|
|
@GSerializable
|
2022-11-01 13:48:23 +01:00
|
|
|
public record ExampleRecord(String hello, @GComment("Sheesh") ExamplePojo2 pojo) {
|
2022-11-01 15:24:59 +01:00
|
|
|
@GPrefer
|
|
|
|
public ExampleRecord(String yes) {
|
|
|
|
this(yes, null);
|
|
|
|
}
|
2022-11-01 11:50:02 +01:00
|
|
|
}
|
2022-11-01 15:39:50 +01:00
|
|
|
|
|
|
|
@GSerializable(builder = Example4.Builder.class)
|
|
|
|
public static class Example4 {
|
|
|
|
public String someField;
|
|
|
|
public boolean shesh;
|
|
|
|
|
|
|
|
public static class Builder {
|
|
|
|
private String someField;
|
|
|
|
private boolean shesh;
|
|
|
|
|
|
|
|
public Builder(String someField) {
|
|
|
|
this.someField = someField;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Builder setShesh(boolean shesh) {
|
|
|
|
this.shesh = shesh;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Example4 build() {
|
|
|
|
Example4 e = new Example4();
|
|
|
|
e.someField = someField;
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-11-01 17:26:32 +01:00
|
|
|
|
|
|
|
public enum EeE {
|
|
|
|
Yes, Yay, Aaee;
|
|
|
|
}
|
2022-11-01 20:40:53 +01:00
|
|
|
|
|
|
|
public static class UnsupportedClass {
|
|
|
|
private final String text;
|
|
|
|
|
|
|
|
public UnsupportedClass(String text) {
|
|
|
|
this.text = text;
|
|
|
|
}
|
|
|
|
}
|
2022-11-13 10:59:19 +01:00
|
|
|
|
|
|
|
public static class Configuration {
|
|
|
|
public static void configure(JsonWriter writer) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void configure(JsonReader reader) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2022-10-31 20:52:48 +01:00
|
|
|
}
|