001 002package com.commercetools.api.models.order; 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 * OrderSearchSortOrder 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface OrderSearchSortOrder extends JsonEnum { 018 019 OrderSearchSortOrder ASC = OrderSearchSortOrderEnum.ASC; 020 021 OrderSearchSortOrder DESC = OrderSearchSortOrderEnum.DESC; 022 023 /** 024 * possible values of OrderSearchSortOrder 025 */ 026 enum OrderSearchSortOrderEnum implements OrderSearchSortOrder { 027 /** 028 * asc 029 */ 030 ASC("asc"), 031 032 /** 033 * desc 034 */ 035 DESC("desc"); 036 private final String jsonName; 037 038 private OrderSearchSortOrderEnum(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 OrderSearchSortOrder 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 OrderSearchSortOrder findEnum(String value) { 078 return findEnumViaJsonName(value).orElse(new OrderSearchSortOrder() { 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<OrderSearchSortOrder> 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 OrderSearchSortOrder[] values() { 109 return OrderSearchSortOrderEnum.values(); 110 } 111 112}