All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tradeshift.sdk.assignments.json.JsonAssignmentLog 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.assignments.domain.AssignmentStatus;
import com.tradeshift.sdk.core.domain.ID;
import com.tradeshift.sdk.core.domain.Identity;

@JsonInclude(Include.NON_NULL)
public class JsonAssignmentLog {

    private final Long id;
    private final String outcome;

    @JsonProperty("status")
    private final AssignmentStatus assignmentStatus;
    private final String comment;

    @JsonSerialize(using = ToStringSerializer.class)
    public final List> assigneeIds;

    @JsonFormat(pattern = JsonDateUtils.DATE_FORMAT)
    public final ZonedDateTime created;

    @JsonSerialize(using = ToStringSerializer.class)
    public final ID assignmentId;

    @JsonCreator
    public JsonAssignmentLog(
            @JsonProperty Long id,
            @JsonProperty String outcome,
            @JsonProperty AssignmentStatus assignmentStatus,
            @JsonProperty String comment,
            @JsonProperty List> assigneeIds,
            @JsonProperty ZonedDateTime created,
            @JsonProperty ID assignmentId) {
        this.id = id;
        this.outcome = outcome;
        this.assignmentStatus = assignmentStatus;
        this.comment = comment;
        this.assigneeIds = assigneeIds;
        this.created = created;
        this.assignmentId = assignmentId;
    }

    public AssignmentLog toDomain() {
        return new AssignmentLog.Builder()
                .setId(id)
                .setOutcome(outcome)
                .setAssignmentStatus(assignmentStatus)
                .setComment(comment)
                .setAssigneeIds(assigneeIds)
                .setCreated(created)
                .setAssignmentId(assignmentId)
                .build();
    }

    public static JsonAssignmentLog of(AssignmentLog a) {
        return new JsonAssignmentLog(a.getId(), a.getOutcome(), a.getAssignmentStatus(), a.getComment(),
                a.getAssigneeIds(), a.getCreated(), a.getAssignmentId());
    }

    public Long getId() {
        return id;
    }

    public String getOutcome() {
        return outcome;
    }

    public AssignmentStatus getAssignmentStatus() {
        return assignmentStatus;
    }

    public String getComment() {
        return comment;
    }

    public List> getAssigneeIds() {
        return assigneeIds;
    }

    public ZonedDateTime getCreated() {
        return created;
    }

    public ID getAssignmentId() {
        return assignmentId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        final JsonAssignmentLog jsonAssignmentLog = (JsonAssignmentLog) o;
        return Objects.equals(id, jsonAssignmentLog.id)
                && Objects.equals(outcome, jsonAssignmentLog.outcome)
                && Objects.equals(assignmentStatus, jsonAssignmentLog.assignmentStatus)
                && Objects.equals(comment, jsonAssignmentLog.comment)
                && Objects.equals(assignmentId, jsonAssignmentLog.assignmentId)
                && Objects.equals(assigneeIds, jsonAssignmentLog.assigneeIds)
                && Objects.equals(created, jsonAssignmentLog.created);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, outcome, assignmentStatus, comment, assignmentId, assigneeIds, created);
    }

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy