diff --git a/.codegen.json b/.codegen.json index 0d0685676..13eb31e69 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "205c0e9", "specHash": "5bf3652", "version": "0.1.0" } +{ "engineHash": "41bba7c", "specHash": "9ccadb1", "version": "0.1.0" } diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java new file mode 100644 index 000000000..f47964532 --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0.java @@ -0,0 +1,93 @@ +package com.box.sdkgen.schemas.v2025r0.userreferencev2025r0; + +import com.box.sdkgen.internal.NullableFieldTracker; +import com.box.sdkgen.internal.SerializableObject; +import com.box.sdkgen.serialization.json.EnumWrapper; +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import java.util.Objects; + +@JsonFilter("nullablePropertyFilter") +public class UserReferenceV2025R0 extends SerializableObject { + + @JsonDeserialize( + using = UserReferenceV2025R0TypeField.UserReferenceV2025R0TypeFieldDeserializer.class) + @JsonSerialize( + using = UserReferenceV2025R0TypeField.UserReferenceV2025R0TypeFieldSerializer.class) + protected EnumWrapper type; + + protected final String id; + + public UserReferenceV2025R0(@JsonProperty("id") String id) { + super(); + this.id = id; + this.type = new EnumWrapper(UserReferenceV2025R0TypeField.USER); + } + + protected UserReferenceV2025R0(Builder builder) { + super(); + this.type = builder.type; + this.id = builder.id; + markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); + } + + public EnumWrapper getType() { + return type; + } + + public String getId() { + return id; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UserReferenceV2025R0 casted = (UserReferenceV2025R0) o; + return Objects.equals(type, casted.type) && Objects.equals(id, casted.id); + } + + @Override + public int hashCode() { + return Objects.hash(type, id); + } + + @Override + public String toString() { + return "UserReferenceV2025R0{" + "type='" + type + '\'' + ", " + "id='" + id + '\'' + "}"; + } + + public static class Builder extends NullableFieldTracker { + + protected EnumWrapper type; + + protected final String id; + + public Builder(String id) { + super(); + this.id = id; + this.type = + new EnumWrapper(UserReferenceV2025R0TypeField.USER); + } + + public Builder type(UserReferenceV2025R0TypeField type) { + this.type = new EnumWrapper(type); + return this; + } + + public Builder type(EnumWrapper type) { + this.type = type; + return this; + } + + public UserReferenceV2025R0 build() { + return new UserReferenceV2025R0(this); + } + } +} diff --git a/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java new file mode 100644 index 000000000..e930f325a --- /dev/null +++ b/src/main/java/com/box/sdkgen/schemas/v2025r0/userreferencev2025r0/UserReferenceV2025R0TypeField.java @@ -0,0 +1,62 @@ +package com.box.sdkgen.schemas.v2025r0.userreferencev2025r0; + +import com.box.sdkgen.serialization.json.EnumWrapper; +import com.box.sdkgen.serialization.json.Valuable; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import java.io.IOException; +import java.util.Arrays; + +public enum UserReferenceV2025R0TypeField implements Valuable { + USER("user"); + + private final String value; + + UserReferenceV2025R0TypeField(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + public static class UserReferenceV2025R0TypeFieldDeserializer + extends JsonDeserializer> { + + public UserReferenceV2025R0TypeFieldDeserializer() { + super(); + } + + @Override + public EnumWrapper deserialize( + JsonParser p, DeserializationContext ctxt) throws IOException { + String value = p.getValueAsString(); + return Arrays.stream(UserReferenceV2025R0TypeField.values()) + .filter((v) -> v.getValue().equalsIgnoreCase(value)) + .findFirst() + .map(EnumWrapper::new) + .orElse(new EnumWrapper(value)); + } + } + + public static class UserReferenceV2025R0TypeFieldSerializer + extends JsonSerializer> { + + public UserReferenceV2025R0TypeFieldSerializer() { + super(); + } + + @Override + public void serialize( + EnumWrapper value, + JsonGenerator gen, + SerializerProvider serializers) + throws IOException { + gen.writeString(value.getStringValue()); + } + } +}