001
002package com.commercetools.api.models.common;
003
004import java.time.*;
005import java.util.*;
006
007import com.fasterxml.jackson.annotation.JsonCreator;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.*;
010
011import io.vrap.rmf.base.client.ModelBase;
012import io.vrap.rmf.base.client.utils.Generated;
013
014import org.apache.commons.lang3.builder.EqualsBuilder;
015import org.apache.commons.lang3.builder.HashCodeBuilder;
016
017/**
018 *  <p>Draft type to create a Reference or a KeyReference to a resource. Provide either the <code>id</code> or (wherever supported) the <code>key</code> of the resource to reference, but depending on the API endpoint the response returns either a Reference or a KeyReference. For example, the field <code>parent</code> of a CategoryDraft takes a ResourceIdentifier for its value while the value of the corresponding field of a Category is a Reference.</p>
019 *  <p>Each resource type has its corresponding ResourceIdentifier, like ChannelResourceIdentifier.</p>
020 */
021@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
022public class ResourceIdentifierImpl implements ResourceIdentifier, ModelBase {
023
024    private com.commercetools.api.models.common.ReferenceTypeId typeId;
025
026    private String id;
027
028    private String key;
029
030    /**
031     * create instance with all properties
032     */
033    @JsonCreator
034    ResourceIdentifierImpl(@JsonProperty("typeId") final com.commercetools.api.models.common.ReferenceTypeId typeId,
035            @JsonProperty("id") final String id, @JsonProperty("key") final String key) {
036        this.typeId = typeId;
037        this.id = id;
038        this.key = key;
039    }
040
041    /**
042     * create empty instance
043     */
044    public ResourceIdentifierImpl() {
045    }
046
047    /**
048     *  <p>Type of referenced resource. If given, it must match the expected ReferenceTypeId of the referenced resource.</p>
049     */
050
051    public com.commercetools.api.models.common.ReferenceTypeId getTypeId() {
052        return this.typeId;
053    }
054
055    /**
056     *  <p>Unique identifier of the referenced resource. Required if <code>key</code> is absent.</p>
057     */
058
059    public String getId() {
060        return this.id;
061    }
062
063    /**
064     *  <p>User-defined unique identifier of the referenced resource. Required if <code>id</code> is absent.</p>
065     */
066
067    public String getKey() {
068        return this.key;
069    }
070
071    public void setId(final String id) {
072        this.id = id;
073    }
074
075    public void setKey(final String key) {
076        this.key = key;
077    }
078
079    @Override
080    public boolean equals(Object o) {
081        if (this == o)
082            return true;
083
084        if (o == null || getClass() != o.getClass())
085            return false;
086
087        ResourceIdentifierImpl that = (ResourceIdentifierImpl) o;
088
089        return new EqualsBuilder().append(typeId, that.typeId)
090                .append(id, that.id)
091                .append(key, that.key)
092                .append(typeId, that.typeId)
093                .append(id, that.id)
094                .append(key, that.key)
095                .isEquals();
096    }
097
098    @Override
099    public int hashCode() {
100        return new HashCodeBuilder(17, 37).append(typeId).append(id).append(key).toHashCode();
101    }
102
103}