001package com.box.sdkgen.schemas.v2025r0.hubaccessgranteev2025r0; 002 003import com.box.sdkgen.internal.OneOfTwo; 004import com.box.sdkgen.schemas.v2025r0.groupminiv2025r0.GroupMiniV2025R0; 005import com.box.sdkgen.schemas.v2025r0.hubcollaborationuserv2025r0.HubCollaborationUserV2025R0; 006import com.box.sdkgen.serialization.json.EnumWrapper; 007import com.box.sdkgen.serialization.json.JsonManager; 008import com.fasterxml.jackson.core.JsonParser; 009import com.fasterxml.jackson.databind.DeserializationContext; 010import com.fasterxml.jackson.databind.JsonDeserializer; 011import com.fasterxml.jackson.databind.JsonMappingException; 012import com.fasterxml.jackson.databind.JsonNode; 013import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 014import com.fasterxml.jackson.databind.annotation.JsonSerialize; 015import java.io.IOException; 016 017@JsonDeserialize(using = HubAccessGranteeV2025R0.HubAccessGranteeV2025R0Deserializer.class) 018@JsonSerialize(using = OneOfTwo.OneOfTwoSerializer.class) 019public class HubAccessGranteeV2025R0 020 extends OneOfTwo<HubCollaborationUserV2025R0, GroupMiniV2025R0> { 021 022 protected final String name; 023 024 protected final String id; 025 026 protected final String type; 027 028 public HubAccessGranteeV2025R0(HubCollaborationUserV2025R0 hubCollaborationUserV2025R0) { 029 super(hubCollaborationUserV2025R0, null); 030 this.name = hubCollaborationUserV2025R0.getName(); 031 this.id = hubCollaborationUserV2025R0.getId(); 032 this.type = EnumWrapper.convertToString(hubCollaborationUserV2025R0.getType()); 033 } 034 035 public HubAccessGranteeV2025R0(GroupMiniV2025R0 groupMiniV2025R0) { 036 super(null, groupMiniV2025R0); 037 this.name = groupMiniV2025R0.getName(); 038 this.id = groupMiniV2025R0.getId(); 039 this.type = EnumWrapper.convertToString(groupMiniV2025R0.getType()); 040 } 041 042 public boolean isHubCollaborationUserV2025R0() { 043 return value0 != null; 044 } 045 046 public HubCollaborationUserV2025R0 getHubCollaborationUserV2025R0() { 047 return value0; 048 } 049 050 public boolean isGroupMiniV2025R0() { 051 return value1 != null; 052 } 053 054 public GroupMiniV2025R0 getGroupMiniV2025R0() { 055 return value1; 056 } 057 058 public String getName() { 059 return name; 060 } 061 062 public String getId() { 063 return id; 064 } 065 066 public String getType() { 067 return type; 068 } 069 070 static class HubAccessGranteeV2025R0Deserializer 071 extends JsonDeserializer<HubAccessGranteeV2025R0> { 072 073 public HubAccessGranteeV2025R0Deserializer() { 074 super(); 075 } 076 077 @Override 078 public HubAccessGranteeV2025R0 deserialize(JsonParser jp, DeserializationContext ctxt) 079 throws IOException { 080 JsonNode node = JsonManager.jsonToSerializedData(jp); 081 JsonNode discriminant0 = node.get("type"); 082 if (!(discriminant0 == null)) { 083 switch (discriminant0.asText()) { 084 case "user": 085 return new HubAccessGranteeV2025R0( 086 JsonManager.deserialize(node, HubCollaborationUserV2025R0.class)); 087 case "group": 088 return new HubAccessGranteeV2025R0( 089 JsonManager.deserialize(node, GroupMiniV2025R0.class)); 090 } 091 } 092 throw new JsonMappingException(jp, "Unable to deserialize HubAccessGranteeV2025R0"); 093 } 094 } 095}