001 002package com.commercetools.importapi.models.orders; 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>Maps to <code>Order.inventoryMode</code>.</p> 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface InventoryMode extends JsonEnum { 018 019 InventoryMode TRACK_ONLY = InventoryModeEnum.TRACK_ONLY; 020 021 InventoryMode RESERVE_ON_ORDER = InventoryModeEnum.RESERVE_ON_ORDER; 022 023 /** 024 * possible values of InventoryMode 025 */ 026 enum InventoryModeEnum implements InventoryMode { 027 /** 028 * TrackOnly 029 */ 030 TRACK_ONLY("TrackOnly"), 031 032 /** 033 * ReserveOnOrder 034 */ 035 RESERVE_ON_ORDER("ReserveOnOrder"); 036 private final String jsonName; 037 038 private InventoryModeEnum(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 InventoryMode 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 InventoryMode findEnum(String value) { 078 return findEnumViaJsonName(value).orElse(new InventoryMode() { 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<InventoryMode> 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 InventoryMode[] values() { 109 return InventoryModeEnum.values(); 110 } 111 112}