001
002package com.commercetools.importapi.models.orders;
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 *  <p>Maps to <code>Order.paymentState</code>.</p>
015 */
016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
017public interface PaymentState extends JsonEnum {
018
019    PaymentState BALANCE_DUE = PaymentStateEnum.BALANCE_DUE;
020
021    PaymentState FAILED = PaymentStateEnum.FAILED;
022
023    PaymentState PENDING = PaymentStateEnum.PENDING;
024
025    PaymentState CREDIT_OWED = PaymentStateEnum.CREDIT_OWED;
026
027    PaymentState PAID = PaymentStateEnum.PAID;
028
029    /**
030     * possible values of PaymentState
031     */
032    enum PaymentStateEnum implements PaymentState {
033        /**
034         * BalanceDue
035         */
036        BALANCE_DUE("BalanceDue"),
037
038        /**
039         * Failed
040         */
041        FAILED("Failed"),
042
043        /**
044         * Pending
045         */
046        PENDING("Pending"),
047
048        /**
049         * CreditOwed
050         */
051        CREDIT_OWED("CreditOwed"),
052
053        /**
054         * Paid
055         */
056        PAID("Paid");
057        private final String jsonName;
058
059        private PaymentStateEnum(final String jsonName) {
060            this.jsonName = jsonName;
061        }
062
063        public String getJsonName() {
064            return jsonName;
065        }
066
067        public String toString() {
068            return jsonName;
069        }
070    }
071
072    /**
073     * the JSON value
074     * @return json value
075     */
076    @JsonValue
077    String getJsonName();
078
079    /**
080     * the enum value
081     * @return name
082     */
083    String name();
084
085    /**
086     * convert value to string
087     * @return string representation
088     */
089    String toString();
090
091    /**
092     * factory method for a enum value of PaymentState
093     * if no enum has been found an anonymous instance will be created
094     * @param value the enum value to be wrapped
095     * @return enum instance
096     */
097    @JsonCreator
098    public static PaymentState findEnum(String value) {
099        return findEnumViaJsonName(value).orElse(new PaymentState() {
100            @Override
101            public String getJsonName() {
102                return value;
103            }
104
105            @Override
106            public String name() {
107                return value.toUpperCase();
108            }
109
110            public String toString() {
111                return value;
112            }
113        });
114    }
115
116    /**
117     * method to find enum using the JSON value
118     * @param jsonName the json value to be wrapped
119     * @return optional of enum instance
120     */
121    public static Optional<PaymentState> findEnumViaJsonName(String jsonName) {
122        return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst();
123    }
124
125    /**
126     * possible enum values
127     * @return array of possible enum values
128     */
129    public static PaymentState[] values() {
130        return PaymentStateEnum.values();
131    }
132
133}