001package com.box.sdkgen.schemas.v2025r0.hubdocumentblockentryv2025r0;
002
003import com.box.sdkgen.internal.OneOfFive;
004import com.box.sdkgen.schemas.v2025r0.hubcalloutboxtextblockv2025r0.HubCalloutBoxTextBlockV2025R0;
005import com.box.sdkgen.schemas.v2025r0.hubdividerblockv2025r0.HubDividerBlockV2025R0;
006import com.box.sdkgen.schemas.v2025r0.hubitemlistblockv2025r0.HubItemListBlockV2025R0;
007import com.box.sdkgen.schemas.v2025r0.hubparagraphtextblockv2025r0.HubParagraphTextBlockV2025R0;
008import com.box.sdkgen.schemas.v2025r0.hubsectiontitletextblockv2025r0.HubSectionTitleTextBlockV2025R0;
009import com.box.sdkgen.serialization.json.EnumWrapper;
010import com.box.sdkgen.serialization.json.JsonManager;
011import com.fasterxml.jackson.core.JsonParser;
012import com.fasterxml.jackson.databind.DeserializationContext;
013import com.fasterxml.jackson.databind.JsonDeserializer;
014import com.fasterxml.jackson.databind.JsonMappingException;
015import com.fasterxml.jackson.databind.JsonNode;
016import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
017import com.fasterxml.jackson.databind.annotation.JsonSerialize;
018import java.io.IOException;
019
020@JsonDeserialize(
021    using = HubDocumentBlockEntryV2025R0.HubDocumentBlockEntryV2025R0Deserializer.class)
022@JsonSerialize(using = OneOfFive.OneOfFiveSerializer.class)
023public class HubDocumentBlockEntryV2025R0
024    extends OneOfFive<
025        HubParagraphTextBlockV2025R0,
026        HubSectionTitleTextBlockV2025R0,
027        HubCalloutBoxTextBlockV2025R0,
028        HubItemListBlockV2025R0,
029        HubDividerBlockV2025R0> {
030
031  protected final String type;
032
033  protected final String id;
034
035  protected final String parentId;
036
037  public HubDocumentBlockEntryV2025R0(HubParagraphTextBlockV2025R0 hubParagraphTextBlockV2025R0) {
038    super(hubParagraphTextBlockV2025R0, null, null, null, null);
039    this.type = EnumWrapper.convertToString(hubParagraphTextBlockV2025R0.getType());
040    this.id = hubParagraphTextBlockV2025R0.getId();
041    this.parentId = hubParagraphTextBlockV2025R0.getParentId();
042  }
043
044  public HubDocumentBlockEntryV2025R0(
045      HubSectionTitleTextBlockV2025R0 hubSectionTitleTextBlockV2025R0) {
046    super(null, hubSectionTitleTextBlockV2025R0, null, null, null);
047    this.type = EnumWrapper.convertToString(hubSectionTitleTextBlockV2025R0.getType());
048    this.id = hubSectionTitleTextBlockV2025R0.getId();
049    this.parentId = hubSectionTitleTextBlockV2025R0.getParentId();
050  }
051
052  public HubDocumentBlockEntryV2025R0(HubCalloutBoxTextBlockV2025R0 hubCalloutBoxTextBlockV2025R0) {
053    super(null, null, hubCalloutBoxTextBlockV2025R0, null, null);
054    this.type = EnumWrapper.convertToString(hubCalloutBoxTextBlockV2025R0.getType());
055    this.id = hubCalloutBoxTextBlockV2025R0.getId();
056    this.parentId = hubCalloutBoxTextBlockV2025R0.getParentId();
057  }
058
059  public HubDocumentBlockEntryV2025R0(HubItemListBlockV2025R0 hubItemListBlockV2025R0) {
060    super(null, null, null, hubItemListBlockV2025R0, null);
061    this.type = EnumWrapper.convertToString(hubItemListBlockV2025R0.getType());
062    this.id = hubItemListBlockV2025R0.getId();
063    this.parentId = hubItemListBlockV2025R0.getParentId();
064  }
065
066  public HubDocumentBlockEntryV2025R0(HubDividerBlockV2025R0 hubDividerBlockV2025R0) {
067    super(null, null, null, null, hubDividerBlockV2025R0);
068    this.type = EnumWrapper.convertToString(hubDividerBlockV2025R0.getType());
069    this.id = hubDividerBlockV2025R0.getId();
070    this.parentId = hubDividerBlockV2025R0.getParentId();
071  }
072
073  public boolean isHubParagraphTextBlockV2025R0() {
074    return value0 != null;
075  }
076
077  public HubParagraphTextBlockV2025R0 getHubParagraphTextBlockV2025R0() {
078    return value0;
079  }
080
081  public boolean isHubSectionTitleTextBlockV2025R0() {
082    return value1 != null;
083  }
084
085  public HubSectionTitleTextBlockV2025R0 getHubSectionTitleTextBlockV2025R0() {
086    return value1;
087  }
088
089  public boolean isHubCalloutBoxTextBlockV2025R0() {
090    return value2 != null;
091  }
092
093  public HubCalloutBoxTextBlockV2025R0 getHubCalloutBoxTextBlockV2025R0() {
094    return value2;
095  }
096
097  public boolean isHubItemListBlockV2025R0() {
098    return value3 != null;
099  }
100
101  public HubItemListBlockV2025R0 getHubItemListBlockV2025R0() {
102    return value3;
103  }
104
105  public boolean isHubDividerBlockV2025R0() {
106    return value4 != null;
107  }
108
109  public HubDividerBlockV2025R0 getHubDividerBlockV2025R0() {
110    return value4;
111  }
112
113  public String getType() {
114    return type;
115  }
116
117  public String getId() {
118    return id;
119  }
120
121  public String getParentId() {
122    return parentId;
123  }
124
125  static class HubDocumentBlockEntryV2025R0Deserializer
126      extends JsonDeserializer<HubDocumentBlockEntryV2025R0> {
127
128    public HubDocumentBlockEntryV2025R0Deserializer() {
129      super();
130    }
131
132    @Override
133    public HubDocumentBlockEntryV2025R0 deserialize(JsonParser jp, DeserializationContext ctxt)
134        throws IOException {
135      JsonNode node = JsonManager.jsonToSerializedData(jp);
136      JsonNode discriminant0 = node.get("type");
137      if (!(discriminant0 == null)) {
138        switch (discriminant0.asText()) {
139          case "paragraph":
140            return new HubDocumentBlockEntryV2025R0(
141                JsonManager.deserialize(node, HubParagraphTextBlockV2025R0.class));
142          case "section_title":
143            return new HubDocumentBlockEntryV2025R0(
144                JsonManager.deserialize(node, HubSectionTitleTextBlockV2025R0.class));
145          case "callout_box":
146            return new HubDocumentBlockEntryV2025R0(
147                JsonManager.deserialize(node, HubCalloutBoxTextBlockV2025R0.class));
148          case "item_list":
149            return new HubDocumentBlockEntryV2025R0(
150                JsonManager.deserialize(node, HubItemListBlockV2025R0.class));
151          case "divider":
152            return new HubDocumentBlockEntryV2025R0(
153                JsonManager.deserialize(node, HubDividerBlockV2025R0.class));
154        }
155      }
156      throw new JsonMappingException(jp, "Unable to deserialize HubDocumentBlockEntryV2025R0");
157    }
158  }
159}