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 * TransactionType
015 */
016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
017public interface TransactionType extends JsonEnum {
018
019    TransactionType AUTHORIZATION = TransactionTypeEnum.AUTHORIZATION;
020
021    TransactionType CANCEL_AUTHORIZATION = TransactionTypeEnum.CANCEL_AUTHORIZATION;
022
023    TransactionType CHARGE = TransactionTypeEnum.CHARGE;
024
025    TransactionType REFUND = TransactionTypeEnum.REFUND;
026
027    TransactionType CHARGEBACK = TransactionTypeEnum.CHARGEBACK;
028
029    /**
030     * possible values of TransactionType
031     */
032    enum TransactionTypeEnum implements TransactionType {
033        /**
034         * Authorization
035         */
036        AUTHORIZATION("Authorization"),
037
038        /**
039         * CancelAuthorization
040         */
041        CANCEL_AUTHORIZATION("CancelAuthorization"),
042
043        /**
044         * Charge
045         */
046        CHARGE("Charge"),
047
048        /**
049         * Refund
050         */
051        REFUND("Refund"),
052
053        /**
054         * Chargeback
055         */
056        CHARGEBACK("Chargeback");
057        private final String jsonName;
058
059        private TransactionTypeEnum(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 TransactionType
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 TransactionType findEnum(String value) {
099        return findEnumViaJsonName(value).orElse(new TransactionType() {
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<TransactionType> 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 TransactionType[] values() {
130        return TransactionTypeEnum.values();
131    }
132
133}