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