001package com.box.sdkgen.managers.shieldinformationbarriersegmentrestrictions; 002 003import com.box.sdkgen.serialization.json.EnumWrapper; 004import com.box.sdkgen.serialization.json.Valuable; 005import com.fasterxml.jackson.annotation.JsonValue; 006import com.fasterxml.jackson.core.JsonGenerator; 007import com.fasterxml.jackson.core.JsonParser; 008import com.fasterxml.jackson.databind.DeserializationContext; 009import com.fasterxml.jackson.databind.JsonDeserializer; 010import com.fasterxml.jackson.databind.JsonSerializer; 011import com.fasterxml.jackson.databind.SerializerProvider; 012import java.io.IOException; 013import java.util.Arrays; 014 015public enum 016 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField 017 implements Valuable { 018 SHIELD_INFORMATION_BARRIER_SEGMENT("shield_information_barrier_segment"); 019 020 private final String value; 021 022 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField( 023 String value) { 024 this.value = value; 025 } 026 027 @JsonValue 028 public String getValue() { 029 return value; 030 } 031 032 public static 033 class CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeFieldDeserializer 034 extends JsonDeserializer< 035 EnumWrapper< 036 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField>> { 037 038 public 039 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeFieldDeserializer() { 040 super(); 041 } 042 043 @Override 044 public EnumWrapper< 045 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField> 046 deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { 047 String value = p.getValueAsString(); 048 return Arrays.stream( 049 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField 050 .values()) 051 .filter((v) -> v.getValue().equalsIgnoreCase(value)) 052 .findFirst() 053 .map(EnumWrapper::new) 054 .orElse( 055 new EnumWrapper< 056 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField>( 057 value)); 058 } 059 } 060 061 public static 062 class CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeFieldSerializer 063 extends JsonSerializer< 064 EnumWrapper< 065 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField>> { 066 067 public 068 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeFieldSerializer() { 069 super(); 070 } 071 072 @Override 073 public void serialize( 074 EnumWrapper< 075 CreateShieldInformationBarrierSegmentRestrictionRequestBodyShieldInformationBarrierSegmentTypeField> 076 value, 077 JsonGenerator gen, 078 SerializerProvider serializers) 079 throws IOException { 080 gen.writeString(value.getStringValue()); 081 } 082 } 083}