Skip to content

Commit 4abf5fc

Browse files
Merge pull request #8 from modzy/feat/adding_lombok
feat: adding lombok to simplify code
2 parents 88186e8 + 1b6ba30 commit 4abf5fc

35 files changed

+171
-1391
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@
4949
<version>4.13-beta-1</version>
5050
<scope>test</scope>
5151
</dependency>
52-
</dependencies>
52+
<dependency>
53+
<groupId>org.projectlombok</groupId>
54+
<artifactId>lombok</artifactId>
55+
<version>RELEASE</version>
56+
<scope>compile</scope>
57+
</dependency>
58+
</dependencies>
5359

5460
<build>
5561
<plugins>

src/main/java/com/modzy/sdk/JobClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public Job submitJob(Model model, ModelVersion modelVersion, JobInput<?> jobInpu
145145
*/
146146
public Job submitJob(String modelId, String modelVersionId, JobInput<?> jobInput) throws ApiException{
147147
Model model = new Model();
148-
model.setModelId(modelId);
148+
model.setIdentifier(modelId);
149149
ModelVersion modelVersion = new ModelVersion();
150150
modelVersion.setVersion(modelVersionId);
151151
return this.submitJob( new Job(model, modelVersion, jobInput) );

src/main/java/com/modzy/sdk/ModelClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Model getModelByName(String modelName) throws ApiException{
149149
searchParams.setName(modelName);
150150
List<Model> models = this.getModels(searchParams);
151151
if( models != null && !models.isEmpty() ){
152-
return this.getModel(models.get(0).getModelId());
152+
return this.getModel(models.get(0).getIdentifier());
153153
}
154154
throw new ApiException("Model "+modelName+" not found");
155155
}
@@ -192,7 +192,7 @@ public List<Model> getRelatedModels(String modelId) throws ApiException{
192192
* @throws ApiException if there is something wrong with the service or the call
193193
*/
194194
public List<Model> getRelatedModels(Model model) throws ApiException{
195-
return this.getRelatedModels(model.getModelId());
195+
return this.getRelatedModels(model.getIdentifier());
196196
}
197197

198198
/**
@@ -229,7 +229,7 @@ public List<ModelVersion> getModelVersions(String modelId) throws ApiException{
229229
* @throws ApiException if there is something wrong with the service or the call
230230
*/
231231
public List<ModelVersion> getModelVersions(Model model) throws ApiException{
232-
return this.getModelVersions(model.getModelId());
232+
return this.getModelVersions(model.getIdentifier());
233233
}
234234

235235
/**

src/main/java/com/modzy/sdk/dto/EmbeddedData.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
44
import com.modzy.sdk.util.EmbeddedSerializer;
5+
import lombok.Data;
56

7+
@Data
68
@JsonSerialize(using = EmbeddedSerializer.class)
79
public class EmbeddedData {
810

@@ -32,29 +34,5 @@ public EmbeddedData(String mediaType, byte[] data) {
3234
this.encoding = "base64";
3335
this.data = data;
3436
}
35-
36-
public String getMediaType() {
37-
return mediaType;
38-
}
39-
40-
public void setMediaType(String mediaType) {
41-
this.mediaType = mediaType;
42-
}
43-
44-
public String getEncoding() {
45-
return encoding;
46-
}
47-
48-
public void setEncoding(String encoding) {
49-
this.encoding = encoding;
50-
}
51-
52-
public byte[] getData() {
53-
return data;
54-
}
55-
56-
public void setData(byte[] data) {
57-
this.data = data;
58-
}
5937

6038
}

src/main/java/com/modzy/sdk/dto/JobHistoryResponseWrapper.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44

55
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
66
import com.modzy.sdk.model.Job;
7+
import lombok.Data;
78

9+
@Data
810
@JsonIgnoreProperties(ignoreUnknown=true)
911
public class JobHistoryResponseWrapper {
1012

1113
private List<Job> data;
1214

13-
public List<Job> getData() {
14-
return data;
15-
}
16-
17-
public void setData(List<Job> data) {
18-
this.data = data;
19-
}
20-
2115
}

src/main/java/com/modzy/sdk/dto/JobHistorySearchParams.java

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
import com.fasterxml.jackson.annotation.JsonInclude;
88
import com.fasterxml.jackson.annotation.JsonInclude.Include;
99
import com.modzy.sdk.model.JobStatus;
10+
import lombok.AllArgsConstructor;
11+
import lombok.Data;
12+
import lombok.NoArgsConstructor;
1013

14+
@Data
15+
@AllArgsConstructor
16+
@NoArgsConstructor
1117
@JsonInclude(Include.NON_EMPTY)
1218
public class JobHistorySearchParams extends Pagination{
1319

@@ -23,71 +29,6 @@ public class JobHistorySearchParams extends Pagination{
2329

2430
private String model;
2531

26-
private JobHistorySearchStatus status;
32+
private JobHistorySearchStatus status = JobHistorySearchStatus.ALL;
2733

28-
public JobHistorySearchParams() {
29-
super();
30-
this.status=JobHistorySearchStatus.ALL;
31-
}
32-
33-
public JobHistorySearchParams(
34-
String user, String accessKey, Date startDate, Date endDate, String model, JobHistorySearchStatus status,
35-
Integer page, Integer perPage, String sortBy, String direction) {
36-
this();
37-
this.user = user;
38-
this.accessKey = accessKey;
39-
this.startDate = startDate;
40-
this.endDate = endDate;
41-
this.model = model;
42-
this.status = status;
43-
this.page = page;
44-
this.perPage = perPage;
45-
this.sortBy = sortBy;
46-
this.direction = direction;
47-
}
48-
49-
public String getUser() {
50-
return user;
51-
}
52-
53-
public void setUser(String user) {
54-
this.user = user;
55-
}
56-
57-
public String getAccessKey() {
58-
return accessKey;
59-
}
60-
61-
public void setAccessKey(String accessKey) {
62-
this.accessKey = accessKey;
63-
}
64-
65-
public Date getStartDate() {
66-
return startDate;
67-
}
68-
69-
public void setStartDate(Date startDate) {
70-
this.startDate = startDate;
71-
}
72-
73-
public Date getEndDate() {
74-
return endDate;
75-
}
76-
77-
public void setEndDate(Date endDate) {
78-
this.endDate = endDate;
79-
}
80-
81-
public String getModel(){return this.model;}
82-
83-
public void setModel(String model){ this.model = model;}
84-
85-
public JobHistorySearchStatus getStatus() {
86-
return status;
87-
}
88-
89-
public void setStatus(JobHistorySearchStatus status) {
90-
this.status = status;
91-
}
92-
9334
}

src/main/java/com/modzy/sdk/dto/ModelSearchParams.java

Lines changed: 13 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@
22

33
import com.fasterxml.jackson.annotation.JsonFormat;
44
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
import lombok.AllArgsConstructor;
7+
import lombok.Data;
8+
import lombok.NoArgsConstructor;
59

610
import java.util.Date;
711

12+
@Data
13+
@AllArgsConstructor
14+
@NoArgsConstructor
815
@JsonInclude(JsonInclude.Include.NON_EMPTY)
916
public class ModelSearchParams extends Pagination{
1017

@@ -18,123 +25,19 @@ public class ModelSearchParams extends Pagination{
1825

1926
protected String description;
2027

21-
protected Boolean isActive;
28+
@JsonProperty("isActive")
29+
protected Boolean active;
2230

23-
protected Boolean isExpired;
31+
@JsonProperty("isExpired")
32+
protected Boolean expired;
2433

25-
protected Boolean isRecommended;
34+
@JsonProperty("isRecommended")
35+
protected Boolean recommended;
2636

2737
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS")
2838
protected Date lastActiveDateTime;
2939

3040
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS")
3141
protected Date expirationDateTime;
3242

33-
public ModelSearchParams(){
34-
super();
35-
this.perPage = 1000;
36-
}
37-
38-
public ModelSearchParams(
39-
String modelId, String author, String createdByEmail, String name,
40-
String description, Boolean isActive, Boolean isExpired, Boolean isRecommended,
41-
Date lastActiveDateTime, Date expirationDateTime,
42-
Integer page, Integer perPage, String sortBy, String direction
43-
) {
44-
this();
45-
this.modelId = modelId;
46-
this.author = author;
47-
this.createdByEmail = createdByEmail;
48-
this.name = name;
49-
this.description = description;
50-
this.isActive = isActive;
51-
this.isExpired = isExpired;
52-
this.isRecommended = isRecommended;
53-
this.lastActiveDateTime = lastActiveDateTime;
54-
this.expirationDateTime = expirationDateTime;
55-
this.page = page;
56-
this.perPage = perPage;
57-
this.sortBy = sortBy;
58-
this.direction = direction;
59-
}
60-
61-
public String getModelId() {
62-
return modelId;
63-
}
64-
65-
public void setModelId(String modelId) {
66-
this.modelId = modelId;
67-
}
68-
69-
public String getAuthor() {
70-
return author;
71-
}
72-
73-
public void setAuthor(String author) {
74-
this.author = author;
75-
}
76-
77-
public String getCreatedByEmail() {
78-
return createdByEmail;
79-
}
80-
81-
public void setCreatedByEmail(String createdByEmail) {
82-
this.createdByEmail = createdByEmail;
83-
}
84-
85-
public String getName() {
86-
return name;
87-
}
88-
89-
public void setName(String name) {
90-
this.name = name;
91-
}
92-
93-
public String getDescription() {
94-
return description;
95-
}
96-
97-
public void setDescription(String description) {
98-
this.description = description;
99-
}
100-
101-
public Boolean getActive() {
102-
return isActive;
103-
}
104-
105-
public void setActive(Boolean active) {
106-
isActive = active;
107-
}
108-
109-
public Boolean getExpired() {
110-
return isExpired;
111-
}
112-
113-
public void setExpired(Boolean expired) {
114-
isExpired = expired;
115-
}
116-
117-
public Boolean getRecommended() {
118-
return isRecommended;
119-
}
120-
121-
public void setRecommended(Boolean recommended) {
122-
isRecommended = recommended;
123-
}
124-
125-
public Date getLastActiveDateTime() {
126-
return lastActiveDateTime;
127-
}
128-
129-
public void setLastActiveDateTime(Date lastActiveDateTime) {
130-
this.lastActiveDateTime = lastActiveDateTime;
131-
}
132-
133-
public Date getExpirationDateTime() {
134-
return expirationDateTime;
135-
}
136-
137-
public void setExpirationDateTime(Date expirationDateTime) {
138-
this.expirationDateTime = expirationDateTime;
139-
}
14043
}

0 commit comments

Comments
 (0)