001 002package com.commercetools.api.models.product_selection; 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>Product Selections can have the following modes:</p> 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface ProductSelectionMode extends JsonEnum { 018 019 /** 020 <p>For this mode of Product Selection, the Products are to be assigned individually by using the <a href="/projects/product-selections#add-product">Add Product</a> update action.</p> 021 022 */ 023 ProductSelectionMode INDIVIDUAL = ProductSelectionModeEnum.INDIVIDUAL; 024 /** 025 <p>Defines the Product Selection to contain Products that are excluded from the catalog. 026 For this mode of Product Selection, the Products are to be excluded individually by using the <a href="/projects/product-selections#exclude-product">Exclude Product</a> update action.</p> 027 028 */ 029 ProductSelectionMode INDIVIDUAL_EXCLUSION = ProductSelectionModeEnum.INDIVIDUAL_EXCLUSION; 030 031 /** 032 * possible values of ProductSelectionMode 033 */ 034 enum ProductSelectionModeEnum implements ProductSelectionMode { 035 /** 036 * Individual 037 */ 038 INDIVIDUAL("Individual"), 039 040 /** 041 * IndividualExclusion 042 */ 043 INDIVIDUAL_EXCLUSION("IndividualExclusion"); 044 private final String jsonName; 045 046 private ProductSelectionModeEnum(final String jsonName) { 047 this.jsonName = jsonName; 048 } 049 050 public String getJsonName() { 051 return jsonName; 052 } 053 054 public String toString() { 055 return jsonName; 056 } 057 } 058 059 /** 060 * the JSON value 061 * @return json value 062 */ 063 @JsonValue 064 String getJsonName(); 065 066 /** 067 * the enum value 068 * @return name 069 */ 070 String name(); 071 072 /** 073 * convert value to string 074 * @return string representation 075 */ 076 String toString(); 077 078 /** 079 * factory method for a enum value of ProductSelectionMode 080 * if no enum has been found an anonymous instance will be created 081 * @param value the enum value to be wrapped 082 * @return enum instance 083 */ 084 @JsonCreator 085 public static ProductSelectionMode findEnum(String value) { 086 return findEnumViaJsonName(value).orElse(new ProductSelectionMode() { 087 @Override 088 public String getJsonName() { 089 return value; 090 } 091 092 @Override 093 public String name() { 094 return value.toUpperCase(); 095 } 096 097 public String toString() { 098 return value; 099 } 100 }); 101 } 102 103 /** 104 * method to find enum using the JSON value 105 * @param jsonName the json value to be wrapped 106 * @return optional of enum instance 107 */ 108 public static Optional<ProductSelectionMode> findEnumViaJsonName(String jsonName) { 109 return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst(); 110 } 111 112 /** 113 * possible enum values 114 * @return array of possible enum values 115 */ 116 public static ProductSelectionMode[] values() { 117 return ProductSelectionModeEnum.values(); 118 } 119 120}