001 002package com.commercetools.history.models.change_history; 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>This type consists of one enum value:</p> 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface DateStringFilter extends JsonEnum { 018 019 DateStringFilter NOW = DateStringFilterEnum.NOW; 020 021 /** 022 * possible values of DateStringFilter 023 */ 024 enum DateStringFilterEnum implements DateStringFilter { 025 /** 026 * now 027 */ 028 NOW("now"); 029 private final String jsonName; 030 031 private DateStringFilterEnum(final String jsonName) { 032 this.jsonName = jsonName; 033 } 034 035 public String getJsonName() { 036 return jsonName; 037 } 038 039 public String toString() { 040 return jsonName; 041 } 042 } 043 044 /** 045 * the JSON value 046 * @return json value 047 */ 048 @JsonValue 049 String getJsonName(); 050 051 /** 052 * the enum value 053 * @return name 054 */ 055 String name(); 056 057 /** 058 * convert value to string 059 * @return string representation 060 */ 061 String toString(); 062 063 /** 064 * factory method for a enum value of DateStringFilter 065 * if no enum has been found an anonymous instance will be created 066 * @param value the enum value to be wrapped 067 * @return enum instance 068 */ 069 @JsonCreator 070 public static DateStringFilter findEnum(String value) { 071 return findEnumViaJsonName(value).orElse(new DateStringFilter() { 072 @Override 073 public String getJsonName() { 074 return value; 075 } 076 077 @Override 078 public String name() { 079 return value.toUpperCase(); 080 } 081 082 public String toString() { 083 return value; 084 } 085 }); 086 } 087 088 /** 089 * method to find enum using the JSON value 090 * @param jsonName the json value to be wrapped 091 * @return optional of enum instance 092 */ 093 public static Optional<DateStringFilter> findEnumViaJsonName(String jsonName) { 094 return Arrays.stream(values()).filter(t -> t.getJsonName().equals(jsonName)).findFirst(); 095 } 096 097 /** 098 * possible enum values 099 * @return array of possible enum values 100 */ 101 public static DateStringFilter[] values() { 102 return DateStringFilterEnum.values(); 103 } 104 105}