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

io.sphere.client.shop.model.DiscountCodeWithState Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.client.shop.model;

import com.google.common.base.Optional;
import io.sphere.client.model.Reference;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;

public class DiscountCodeWithState {
    private final Optional state;
    private final Reference discountCode;

    @JsonCreator
    DiscountCodeWithState(@JsonProperty("state") DiscountCodeState state,
                          @JsonProperty("discountCode") Reference discountCode) {
        this(Optional.fromNullable(state), discountCode);
    }

    @JsonIgnore
    public DiscountCodeWithState(final Optional state, final Reference discountCode) {
        this.state = state;
        this.discountCode = discountCode;
    }

    public Optional getState() {
        return state;
    }

    public Reference getDiscountCode() {
        return discountCode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        DiscountCodeWithState that = (DiscountCodeWithState) o;

        if (discountCode != null ? !discountCode.equals(that.discountCode) : that.discountCode != null) return false;
        if (state != null ? !state.equals(that.state) : that.state != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = state != null ? state.hashCode() : 0;
        result = 31 * result + (discountCode != null ? discountCode.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "DiscountCodeWithState{" +
                "state=" + state +
                ", reference=" + discountCode +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy