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 * <p>Indicates whether the Business Unit can be edited and used in Carts, Orders, Quote Requests, or Quotes.</p> 015 */ 016@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 017public interface BusinessUnitStatus extends JsonEnum { 018 019 BusinessUnitStatus ACTIVE = BusinessUnitStatusEnum.ACTIVE; 020 021 BusinessUnitStatus INACTIVE = BusinessUnitStatusEnum.INACTIVE; 022 023 /** 024 * possible values of BusinessUnitStatus 025 */ 026 enum BusinessUnitStatusEnum implements BusinessUnitStatus { 027 /** 028 * Active 029 */ 030 ACTIVE("Active"), 031 032 /** 033 * Inactive 034 */ 035 INACTIVE("Inactive"); 036 private final String jsonName; 037 038 private BusinessUnitStatusEnum(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 BusinessUnitStatus 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 BusinessUnitStatus findEnum(String value) { 078 return findEnumViaJsonName(value).orElse(new BusinessUnitStatus() { 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<BusinessUnitStatus> 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 BusinessUnitStatus[] values() { 109 return BusinessUnitStatusEnum.values(); 110 } 111 112}