com.tradeshift.sdk.assignments.json.JsonAssignment Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2018 Tradeshift Inc. and/or its affiliates. All rights reserved.
*/
package com.tradeshift.sdk.assignments.json;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.tradeshift.sdk.assignments.domain.Assignment;
import com.tradeshift.sdk.assignments.domain.AssignmentLog;
import com.tradeshift.sdk.core.domain.ID;
import com.tradeshift.sdk.core.domain.SecurityGroup;
import com.tradeshift.sdk.core.domain.User;
@JsonInclude(Include.NON_NULL)
public class JsonAssignment {
@JsonSerialize(using = ToStringSerializer.class)
private final ID id;
private final String primarySubject;
private final String app;
@JsonSerialize(using = ToStringSerializer.class)
private final ID assignerId;
@JsonSerialize(using = ToStringSerializer.class)
private final ID companyId;
private final List tags;
@JsonFormat(pattern = JsonDateUtils.DATE_FORMAT)
private final ZonedDateTime reminderDate;
@JsonFormat(pattern = JsonDateUtils.DATE_FORMAT)
private final ZonedDateTime deadlineDate;
private final Boolean important;
private final Boolean hold;
private final String type;
@JsonFormat(pattern = JsonDateUtils.DATE_FORMAT)
private final ZonedDateTime created;
@JsonFormat(pattern = JsonDateUtils.DATE_FORMAT)
private final ZonedDateTime modified;
@JsonProperty("assignmentLog")
private final JsonAssignmentLog jsonAssignmentLog;
@JsonCreator
public JsonAssignment(
@JsonProperty ID id,
@JsonProperty String primarySubject,
@JsonProperty String app,
@JsonProperty ID assignerId,
@JsonProperty ID companyId,
@JsonProperty List tags,
@JsonProperty ZonedDateTime reminderDate,
@JsonProperty ZonedDateTime deadlineDate,
@JsonProperty Boolean important,
@JsonProperty Boolean hold,
@JsonProperty String type,
@JsonProperty ZonedDateTime created,
@JsonProperty ZonedDateTime modified,
@JsonProperty JsonAssignmentLog jsonAssignmentLog) {
this.id = id;
this.primarySubject = primarySubject;
this.app = app;
this.assignerId = assignerId;
this.companyId = companyId;
this.tags = tags;
this.reminderDate = reminderDate;
this.deadlineDate = deadlineDate;
this.important = important;
this.hold = hold;
this.type = type;
this.created = created;
this.modified = modified;
this.jsonAssignmentLog = jsonAssignmentLog;
}
public ID getId() {
return id;
}
public String getPrimarySubject() {
return primarySubject;
}
public String getApp() {
return app;
}
public ID getAssignerId() {
return assignerId;
}
public ID getCompanyId() {
return companyId;
}
public List getTags() {
return tags;
}
public ZonedDateTime getReminderDate() {
return reminderDate;
}
public ZonedDateTime getDeadlineDate() {
return deadlineDate;
}
public Boolean getImportant() {
return important;
}
public Boolean getHold() {
return hold;
}
public String getType() {
return type;
}
public ZonedDateTime getCreated() {
return created;
}
public ZonedDateTime getModified() {
return modified;
}
public JsonAssignmentLog getJsonAssignmentLog() {
return jsonAssignmentLog;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final JsonAssignment jsonAssignment = (JsonAssignment) o;
return Objects.equals(id, jsonAssignment.id)
&& Objects.equals(primarySubject, jsonAssignment.primarySubject)
&& Objects.equals(app, jsonAssignment.app)
&& Objects.equals(assignerId, jsonAssignment.assignerId)
&& Objects.equals(companyId, jsonAssignment.companyId)
&& Objects.equals(tags, jsonAssignment.tags)
&& Objects.equals(reminderDate, jsonAssignment.reminderDate)
&& Objects.equals(deadlineDate, jsonAssignment.deadlineDate)
&& Objects.equals(important, jsonAssignment.important)
&& Objects.equals(hold, jsonAssignment.hold)
&& Objects.equals(type, jsonAssignment.type)
&& Objects.equals(created, jsonAssignment.created)
&& Objects.equals(modified, jsonAssignment.modified)
&& Objects.equals(jsonAssignmentLog, jsonAssignment.jsonAssignmentLog);
}
@Override
public int hashCode() {
return Objects.hash(id, primarySubject, app, assignerId, companyId, tags, reminderDate,
deadlineDate, important, hold, type, created, modified, jsonAssignmentLog);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
public Assignment toDomain() {
AssignmentLog assignmentLog = new AssignmentLog.Builder()
.setAssigneeIds(jsonAssignmentLog.getAssigneeIds())
.setAssignmentId(jsonAssignmentLog.getAssignmentId())
.setComment(jsonAssignmentLog.getComment())
.setCreated(jsonAssignmentLog.getCreated())
.setId(jsonAssignmentLog.getId())
.setOutcome(jsonAssignmentLog.getOutcome())
.setAssignmentStatus(jsonAssignmentLog.getAssignmentStatus())
.build();
return new Assignment.Builder()
.setId(id)
.setPrimarySubject(primarySubject)
.setApp(app)
.setAssignerId(assignerId)
.setCompanyId(companyId)
.setTags(tags)
.setReminderDate(reminderDate)
.setDeadlineDate(deadlineDate)
.setImportant(important)
.setHold(hold)
.setType(type)
.setCreated(created)
.setModified(modified)
.setAssignmentLog(assignmentLog)
.build();
}
public static JsonAssignment of(Assignment a) {
JsonAssignmentLog log = a.getAssignmentLog() != null ? JsonAssignmentLog.of(a.getAssignmentLog()) : null;
return new JsonAssignment(a.getId(), a.getPrimarySubject(), a.getApp(), a.getAssignerId(),
a.getCompanyId(), a.getTags(), a.getReminderDate(), a.getDeadlineDate(), a.getImportant(),
a.getHold(), a.getType(), a.getCreated(), a.getModified(), log);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy