001
002package com.commercetools.api.models.custom_object;
003
004import java.time.ZonedDateTime;
005
006import com.fasterxml.jackson.annotation.JsonCreator;
007import com.fasterxml.jackson.annotation.JsonProperty;
008
009import org.apache.commons.lang3.builder.EqualsBuilder;
010import org.apache.commons.lang3.builder.HashCodeBuilder;
011
012/**
013 * generic custom object implementation
014 * @param <TValue> The type of the value of this custom object.
015 */
016public class GenericCustomObjectImpl<TValue> implements GenericCustomObject<TValue> {
017
018    private String id;
019
020    private Long version;
021
022    private ZonedDateTime createdAt;
023
024    private ZonedDateTime lastModifiedAt;
025
026    private com.commercetools.api.models.common.LastModifiedBy lastModifiedBy;
027
028    private com.commercetools.api.models.common.CreatedBy createdBy;
029
030    private String container;
031
032    private String key;
033
034    private TValue value;
035
036    @JsonCreator
037    public GenericCustomObjectImpl(@JsonProperty("id") final String id, @JsonProperty("version") final Long version,
038            @JsonProperty("createdAt") final ZonedDateTime createdAt,
039            @JsonProperty("lastModifiedAt") final ZonedDateTime lastModifiedAt,
040            @JsonProperty("lastModifiedBy") final com.commercetools.api.models.common.LastModifiedBy lastModifiedBy,
041            @JsonProperty("createdBy") final com.commercetools.api.models.common.CreatedBy createdBy,
042            @JsonProperty("container") final String container, @JsonProperty("key") final String key,
043            @JsonProperty("value") final TValue value) {
044        this.id = id;
045        this.version = version;
046        this.createdAt = createdAt;
047        this.lastModifiedAt = lastModifiedAt;
048        this.lastModifiedBy = lastModifiedBy;
049        this.createdBy = createdBy;
050        this.container = container;
051        this.key = key;
052        this.value = value;
053    }
054
055    public GenericCustomObjectImpl() {
056    }
057
058    public String getId() {
059        return this.id;
060    }
061
062    public Long getVersion() {
063        return this.version;
064    }
065
066    public ZonedDateTime getCreatedAt() {
067        return this.createdAt;
068    }
069
070    public ZonedDateTime getLastModifiedAt() {
071        return this.lastModifiedAt;
072    }
073
074    /**
075    *  <p>Present on resources created after 2019-02-01 except for <a href="/client-logging#events-tracked">events not tracked</a>.</p>
076    */
077    public com.commercetools.api.models.common.LastModifiedBy getLastModifiedBy() {
078        return this.lastModifiedBy;
079    }
080
081    /**
082    *  <p>Present on resources created after 2019-02-01 except for <a href="/client-logging#events-tracked">events not tracked</a>.</p>
083    */
084    public com.commercetools.api.models.common.CreatedBy getCreatedBy() {
085        return this.createdBy;
086    }
087
088    /**
089    *  <p>A namespace to group custom objects.</p>
090    */
091    public String getContainer() {
092        return this.container;
093    }
094
095    public String getKey() {
096        return this.key;
097    }
098
099    public TValue getValue() {
100        return this.value;
101    }
102
103    public void setId(final String id) {
104        this.id = id;
105    }
106
107    public void setVersion(final Long version) {
108        this.version = version;
109    }
110
111    public void setCreatedAt(final ZonedDateTime createdAt) {
112        this.createdAt = createdAt;
113    }
114
115    public void setLastModifiedAt(final ZonedDateTime lastModifiedAt) {
116        this.lastModifiedAt = lastModifiedAt;
117    }
118
119    public void setLastModifiedBy(final com.commercetools.api.models.common.LastModifiedBy lastModifiedBy) {
120        this.lastModifiedBy = lastModifiedBy;
121    }
122
123    public void setCreatedBy(final com.commercetools.api.models.common.CreatedBy createdBy) {
124        this.createdBy = createdBy;
125    }
126
127    public void setContainer(final String container) {
128        this.container = container;
129    }
130
131    public void setKey(final String key) {
132        this.key = key;
133    }
134
135    public void setValue(final TValue value) {
136        this.value = value;
137    }
138
139    @Override
140    public boolean equals(Object o) {
141        if (this == o)
142            return true;
143
144        if (o == null || getClass() != o.getClass())
145            return false;
146
147        GenericCustomObjectImpl that = (GenericCustomObjectImpl) o;
148
149        return new EqualsBuilder().append(id, that.id)
150                .append(version, that.version)
151                .append(createdAt, that.createdAt)
152                .append(lastModifiedAt, that.lastModifiedAt)
153                .append(lastModifiedBy, that.lastModifiedBy)
154                .append(createdBy, that.createdBy)
155                .append(container, that.container)
156                .append(key, that.key)
157                .append(value, that.value)
158                .isEquals();
159    }
160
161    @Override
162    public int hashCode() {
163        return new HashCodeBuilder(17, 37).append(id)
164                .append(version)
165                .append(createdAt)
166                .append(lastModifiedAt)
167                .append(lastModifiedBy)
168                .append(createdBy)
169                .append(container)
170                .append(key)
171                .append(value)
172                .toHashCode();
173    }
174
175}