001
002package com.commercetools.history.models.common;
003
004import java.util.Arrays;
005import java.util.Optional;
006
007import com.fasterxml.jackson.annotation.JsonCreator;
008import com.fasterxml.jackson.annotation.JsonValue;
009
010import io.vrap.rmf.base.client.JsonEnum;
011import io.vrap.rmf.base.client.utils.Generated;
012
013/**
014 * DiscountCodeState
015 */
016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
017public interface DiscountCodeState extends JsonEnum {
018
019    DiscountCodeState NOT_ACTIVE = DiscountCodeStateEnum.NOT_ACTIVE;
020
021    DiscountCodeState DOES_NOT_MATCH_CART = DiscountCodeStateEnum.DOES_NOT_MATCH_CART;
022
023    DiscountCodeState MATCHES_CART = DiscountCodeStateEnum.MATCHES_CART;
024
025    DiscountCodeState MAX_APPLICATION_REACHED = DiscountCodeStateEnum.MAX_APPLICATION_REACHED;
026
027    DiscountCodeState APPLICATION_STOPPED_BY_PREVIOUS_DISCOUNT = DiscountCodeStateEnum.APPLICATION_STOPPED_BY_PREVIOUS_DISCOUNT;
028
029    DiscountCodeState NOT_VALID = DiscountCodeStateEnum.NOT_VALID;
030
031    /**
032     * possible values of DiscountCodeState
033     */
034    enum DiscountCodeStateEnum implements DiscountCodeState {
035        /**
036         * NotActive
037         */
038        NOT_ACTIVE("NotActive"),
039
040        /**
041         * DoesNotMatchCart
042         */
043        DOES_NOT_MATCH_CART("DoesNotMatchCart"),
044
045        /**
046         * MatchesCart
047         */
048        MATCHES_CART("MatchesCart"),
049
050        /**
051         * MaxApplicationReached
052         */
053        MAX_APPLICATION_REACHED("MaxApplicationReached"),
054
055        /**
056         * ApplicationStoppedByPreviousDiscount
057         */
058        APPLICATION_STOPPED_BY_PREVIOUS_DISCOUNT("ApplicationStoppedByPreviousDiscount"),
059
060        /**
061         * NotValid
062         */
063        NOT_VALID("NotValid");
064        private final String jsonName;
065
066        private DiscountCodeStateEnum(final String jsonName) {
067            this.jsonName = jsonName;
068        }
069
070        public String getJsonName() {
071            return jsonName;
072        }
073
074        public String toString() {
075            return jsonName;
076        }
077    }
078
079    /**
080     * the JSON value
081     * @return json value
082     */
083    @JsonValue
084    String getJsonName();
085
086    /**
087     * the enum value
088     * @return name
089     */
090    String name();
091
092    /**
093     * convert value to string
094     * @return string representation
095     */
096    String toString();
097
098    /**
099     * factory method for a enum value of DiscountCodeState
100     * if no enum has been found an anonymous instance will be created
101     * @param value the enum value to be wrapped
102     * @return enum instance
103     */
104    @JsonCreator
105    public static DiscountCodeState findEnum(String value) {
106        return findEnumViaJsonName(value).orElse(new DiscountCodeState() {
107            @Override
108            public String getJsonName() {
109                return value;
110            }
111
112            @Override
113            public String name() {
114                return value.toUpperCase();
115            }
116
117            public String toString() {
118                return value;
119            }
120        });
121    }
122
123    /**
124     * method to find enum using the JSON value
125     * @param jsonName the json value to be wrapped
126     * @return optional of enum instance
127     */
128    public static Optional<DiscountCodeState> findEnumViaJsonName(String jsonName) {
129        return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst();
130    }
131
132    /**
133     * possible enum values
134     * @return array of possible enum values
135     */
136    public static DiscountCodeState[] values() {
137        return DiscountCodeStateEnum.values();
138    }
139
140}