Skip to content

chore: add @Builder in java #633

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand All @@ -81,115 +82,116 @@ public class User extends Resource {


@ToString
@Builder
static public class ScimName {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("givenName")
@Getter @Setter private String givenName;
private String givenName;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("familyName")
@Getter @Setter private String familyName;
private String familyName;


public static ScimName fromJson(String jsonString, ObjectMapper mapper) throws IOException {
return mapper.readValue(jsonString, ScimName.class);
}
}
@ToString
@Builder
static public class ScimEmailAddress {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("primary")
@Getter @Setter private Boolean primary;
private Boolean primary;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("value")
@Getter @Setter private String value;
private String value;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("type")
@Getter @Setter private String type;
private String type;


public static ScimEmailAddress fromJson(String jsonString, ObjectMapper mapper) throws IOException {
return mapper.readValue(jsonString, ScimEmailAddress.class);
}
}
@ToString
@Builder
static public class ScimMeta {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("resourceType")
@Getter @Setter private String resourceType;
private String resourceType;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("created")
@Getter @Setter private ZonedDateTime created;
private ZonedDateTime created;
public String getCreated() {
return created.toInstant().toString();
}
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("lastModified")
@Getter @Setter private ZonedDateTime lastModified;
private ZonedDateTime lastModified;
public String getLastModified() {
return lastModified.toInstant().toString();
}
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("version")
@Getter @Setter private String version;
private String version;


public static ScimMeta fromJson(String jsonString, ObjectMapper mapper) throws IOException {
return mapper.readValue(jsonString, ScimMeta.class);
}
}
@ToString
@Builder
static public class ScimUser {
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("id")
@Getter @Setter private String id;
private String id;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("externalId")
@Getter @Setter private String externalId;
private String externalId;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("userName")
@Getter @Setter private String userName;
private String userName;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("displayName")
@Getter @Setter private String displayName;
private String displayName;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("name")
@Getter @Setter private ScimName name;
private ScimName name;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("emails")
@Getter @Setter private List<ScimEmailAddress> emails;
private List<ScimEmailAddress> emails;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("active")
@Getter @Setter private Boolean active;
private Boolean active;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("locale")
@Getter @Setter private String locale;
private String locale;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("timezone")
@Getter @Setter private String timezone;
private String timezone;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("schemas")
@Getter @Setter private List<String> schemas;
private List<String> schemas;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("meta")
@Getter @Setter private ScimMeta meta;
private ScimMeta meta;

public ScimUser(final String userName ) {
this.userName = userName;
}

public static ScimUser fromJson(String jsonString, ObjectMapper mapper) throws IOException {
return mapper.readValue(jsonString, ScimUser.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/twilio-java/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.Builder;

import java.util.Map;
import java.time.LocalDate;
Expand Down
14 changes: 3 additions & 11 deletions src/main/resources/twilio-java/models.mustache
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@

{{#resources.nestedModels}}
@ToString
@Builder
static public class {{classname}} {
{{#vars}}
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonProperty("{{{baseName}}}")
@Getter @Setter private {{{dataType}}} {{name}};
private {{{dataType}}} {{name}};
{{^isMap}}
{{#vendorExtensions.x-serialize}}
public String get{{#lambda.titlecase}}{{name}}{{/lambda.titlecase}}() {
return {{vendorExtensions.x-serialize}};
}{{/vendorExtensions.x-serialize}}
{{/isMap}}
{{/vars}}
{{#vendorExtensions.x-constructor-required}}
{{#modelParameters}}
public {{classname}}({{#.}}final {{{dataType}}} {{name}}{{^-last}}, {{/-last}}{{/.}} ) {
{{#.}}
this.{{name}} = {{name}};
{{/.}}
}
{{/modelParameters}}
{{/vendorExtensions.x-constructor-required}}

{{^vendorExtensions.x-response}}
public static {{classname}} fromJson(String jsonString, ObjectMapper mapper) throws IOException {
return mapper.readValue(jsonString, {{classname}}.class);
}
{{/vendorExtensions.x-response}}
}
{{/resources.nestedModels}}
{{/resources.nestedModels}}
Loading