001
002package com.commercetools.api.models.product_type;
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 * AttributeConstraintEnumDraft
015 */
016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
017public interface AttributeConstraintEnumDraft extends JsonEnum {
018
019    AttributeConstraintEnumDraft NONE = AttributeConstraintEnumDraftEnum.NONE;
020
021    /**
022     * possible values of AttributeConstraintEnumDraft
023     */
024    enum AttributeConstraintEnumDraftEnum implements AttributeConstraintEnumDraft {
025        /**
026         * None
027         */
028        NONE("None");
029        private final String jsonName;
030
031        private AttributeConstraintEnumDraftEnum(final String jsonName) {
032            this.jsonName = jsonName;
033        }
034
035        public String getJsonName() {
036            return jsonName;
037        }
038
039        public String toString() {
040            return jsonName;
041        }
042    }
043
044    /**
045     * the JSON value
046     * @return json value
047     */
048    @JsonValue
049    String getJsonName();
050
051    /**
052     * the enum value
053     * @return name
054     */
055    String name();
056
057    /**
058     * convert value to string
059     * @return string representation
060     */
061    String toString();
062
063    /**
064     * factory method for a enum value of AttributeConstraintEnumDraft
065     * if no enum has been found an anonymous instance will be created
066     * @param value the enum value to be wrapped
067     * @return enum instance
068     */
069    @JsonCreator
070    public static AttributeConstraintEnumDraft findEnum(String value) {
071        return findEnumViaJsonName(value).orElse(new AttributeConstraintEnumDraft() {
072            @Override
073            public String getJsonName() {
074                return value;
075            }
076
077            @Override
078            public String name() {
079                return value.toUpperCase();
080            }
081
082            public String toString() {
083                return value;
084            }
085        });
086    }
087
088    /**
089     * method to find enum using the JSON value
090     * @param jsonName the json value to be wrapped
091     * @return optional of enum instance
092     */
093    public static Optional<AttributeConstraintEnumDraft> findEnumViaJsonName(String jsonName) {
094        return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst();
095    }
096
097    /**
098     * possible enum values
099     * @return array of possible enum values
100     */
101    public static AttributeConstraintEnumDraft[] values() {
102        return AttributeConstraintEnumDraftEnum.values();
103    }
104
105}