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