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