All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.java.com.nutanix.dp1.net.networking.v4.config.FloatingIpListApiResponse Maven / Gradle / Ivy

/*
 * Generated file ..
 *
 * Product version: 4.0.1-beta-1
 *
 * Part of the Nutanix Networking Versioned APIs
 *
 * (c) 2023 Nutanix Inc.  All rights reserved
 *
 */

package com.nutanix.dp1.net.networking.v4.config;

import com.fasterxml.jackson.annotation.JsonAnySetter;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.AccessLevel;
import com.nutanix.devplatform.models.PrettyModeViews.*;
import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.nutanix.dp1.net.deserializers.NetObjectTypeTypedObject;

import javax.validation.constraints.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.nutanix.dp1.net.deserializers.NetDeserializerUtils.*;


/**
 * REST response for all response codes in API path /networking/v4.0.b1/config/floating-ips Get operation
 */



@Data
@lombok.extern.slf4j.Slf4j
public class FloatingIpListApiResponse implements java.io.Serializable, NetObjectTypeTypedObject {

  

  public FloatingIpListApiResponse() {

    this.$objectType = this.initialize$objectType();
    this.$reserved = new java.util.LinkedHashMap<>();
    this.$reserved.put("$fqObjectType", this.initialize$fqObjectType());
    this.$unknownFields = new java.util.LinkedHashMap<>();

  }

  @lombok.Builder(builderMethodName = "FloatingIpListApiResponseBuilder")
  public FloatingIpListApiResponse(com.nutanix.dp1.net.common.v1.response.ApiResponseMetadata metadata, Object data) {
    this.$objectType = this.initialize$objectType();
    this.$reserved = new java.util.LinkedHashMap<>();
    this.$reserved.put("$fqObjectType", this.initialize$fqObjectType());
    this.$unknownFields = new java.util.LinkedHashMap<>();

    this.setMetadata(metadata);
    this.setDataInWrapper(data);
      }


  protected String initialize$objectType() {
    return "networking.v4.config.FloatingIpListApiResponse";
  }


  protected String initialize$fqObjectType() {
    return "networking.v4.r0.b1.config.FloatingIpListApiResponse";
  }

  @JsonAnySetter
  private void setUndeserializedFields(String name, String value) {
    $unknownFields.put(name, value);
  }


  
  

  
    /**
    * 
    */
    
    @JsonProperty("metadata")
    public com.nutanix.dp1.net.common.v1.response.ApiResponseMetadata metadata = null;
  
  
    
    
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Getter
    private String $dataItemDiscriminator = null;
    
    @Data
    @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OneOfDataWrapper.OneOfDataWrapperJsonDeserializer.class)
    public static class OneOfDataWrapper {
    
      private static final java.util.List EMPTY_LIST = new java.util.ArrayList<>();
    
      public OneOfDataWrapper() {
      }
    
      public OneOfDataWrapper(java.util.List data) {
        if(data.isEmpty()) {
          this.discriminator = "EMPTY_LIST";
          this.$objectType = "EMPTY_LIST";
          return;
        }
        Class cls = data.get(0).getClass();
        if(com.nutanix.dp1.net.networking.v4.config.FloatingIp.class.equals(cls)) {
          this.oneOfType0 = (java.util.List) data;
          this.discriminator = "List";
          this.$objectType = "List";
          return;
        }
        if(com.nutanix.dp1.net.networking.v4.config.FloatingIpProjection.class.equals(cls)) {
          this.oneOfType401 = (java.util.List) data;
          this.discriminator = "List";
          this.$objectType = "List";
          return;
        }
        throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfDataWrapper:" + data.getClass().getName());
      }
    
    
      public OneOfDataWrapper(com.nutanix.dp1.net.networking.v4.error.ErrorResponse data) {
        this.oneOfType400 = data;

        this.discriminator = data.get$objectType();
        this.$objectType = data.get$objectType();
      }
    
      @com.nutanix.dp1.net.annotations.NetJsonDeserializer
      @org.springframework.stereotype.Component("com.nutanix.dp1.net.networking.v4.config.FloatingIpListApiResponseJsonDeserializer")
      private static class OneOfDataWrapperJsonDeserializer extends com.nutanix.dp1.net.deserializers.NetOneOfDeserializer  {
        private static final com.fasterxml.jackson.databind.type.TypeFactory TYPE_FACTORY = com.fasterxml.jackson.databind.type.TypeFactory.defaultInstance();
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE0 = TYPE_FACTORY.constructCollectionType(java.util.List.class, com.nutanix.dp1.net.networking.v4.config.FloatingIp.class);
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE400 = TYPE_FACTORY.constructType(com.nutanix.dp1.net.networking.v4.error.ErrorResponse.class);
        private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE401 = TYPE_FACTORY.constructCollectionType(java.util.List.class, com.nutanix.dp1.net.networking.v4.config.FloatingIpProjection.class);
    
        public OneOfDataWrapperJsonDeserializer() {
          super(TYPE_FACTORY.constructType(OneOfDataWrapper.class));
        }
    
        @Override
        protected void setDataObject(OneOfDataWrapper oneOfObject, Object nestedObject) {
          if (oneOfObject == null) {
            throw new IllegalArgumentException("Instance of OneOfDataWrapper provided is null");
          }
          if(ONE_OF_TYPE0.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
          }
          else if(ONE_OF_TYPE400.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
          }
          else if(ONE_OF_TYPE401.getRawClass().isAssignableFrom(nestedObject.getClass())) {
            oneOfObject.setValue(nestedObject);
          }
          else {
            throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfDataWrapper:" + nestedObject.getClass().getName());
          }
        }
    
        public String getPackagePrefix() {
          return "com.nutanix.dp1.net";
        }
      }
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)
      private java.util.List oneOfType0;
            @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)

      private com.nutanix.dp1.net.networking.v4.error.ErrorResponse oneOfType400;
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Getter(lombok.AccessLevel.NONE)
      @lombok.Setter(lombok.AccessLevel.NONE)
      private java.util.List oneOfType401;
          
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String discriminator;
    
    
      @com.fasterxml.jackson.annotation.JsonIgnore
      @lombok.Setter(lombok.AccessLevel.NONE)
      private String $objectType;
    
      @com.fasterxml.jackson.annotation.JsonGetter
      public Object getValue() {
        if("EMPTY_LIST".equals(this.discriminator)) {
          return EMPTY_LIST;
        }
        if("List".equals(this.discriminator)) {
          return this.oneOfType0;
        }
        
        if(oneOfType400 != null && oneOfType400.get$objectType().equals(this.discriminator)) {
          return this.oneOfType400;
        }
        if("List".equals(this.discriminator)) {
          return this.oneOfType401;
        }
                throw new IllegalArgumentException("Unrecognized discriminator:" + this.discriminator);
      }
    
      public void setValue(Object value) {
        if(value == null) {

          log.warn("null passed to setValue function. OneOf's value will not be set.");
          return;
        }
    
        if(setOneOfType0(value)) {
          return;
        }
        
        if(com.nutanix.dp1.net.networking.v4.error.ErrorResponse.class.getName().equals(value.getClass().getName())) {
          this.oneOfType400 = (com.nutanix.dp1.net.networking.v4.error.ErrorResponse) value;

          this.discriminator = this.oneOfType400.get$objectType();
          this.$objectType = this.oneOfType400.get$objectType();
          return;
        }
        if(setOneOfType401(value)) {
          return;
        }
                throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfDataWrapper:" + value.getClass().getName());
      }
    
      private boolean setOneOfType0(Object value) {
        Class valueClass = com.nutanix.dp1.net.networking.v4.config.FloatingIp.class;
        if(java.util.List.class.isAssignableFrom(value.getClass())) {
          // list try to match types if list is not empty.
          if (((java.util.List) value).size() > 0) {
            // Do some extra type checking
            if (valueClass.equals(((java.util.List) value).get(0).getClass())) {
              this.discriminator = "List";
              this.$objectType = "List";
              this.oneOfType0 = (java.util.List) value;
              return true;
            }
            return false;
          } else {
            this.discriminator = "EMPTY_LIST";
            this.$objectType = "EMPTY_LIST";
            this.oneOfType0 = (List) value;
            return true;
          }
        }
        return false;
      }
    
      private boolean setOneOfType401(Object value) {
        Class valueClass = com.nutanix.dp1.net.networking.v4.config.FloatingIpProjection.class;
        if(java.util.List.class.isAssignableFrom(value.getClass())) {
          // list try to match types if list is not empty.
          if (((java.util.List) value).size() > 0) {
            // Do some extra type checking
            if (valueClass.equals(((java.util.List) value).get(0).getClass())) {
              this.discriminator = "List";
              this.$objectType = "List";
              this.oneOfType401 = (java.util.List) value;
              return true;
            }
            return false;
          } else {
            this.discriminator = "EMPTY_LIST";
            this.$objectType = "EMPTY_LIST";
            this.oneOfType401 = (List) value;
            return true;
          }
        }
        return false;
      }
    
    }
  
    private OneOfDataWrapper data = null;
  
    /**
     * @deprecated
     * @param value one of wrapper instance
     */
    public void setData(OneOfDataWrapper value) {
      log.warn("Deprecating this method, please use setDataInWrapper instead");
      if (value == null) {
        return;
      }
      this.data = value;
      this.$dataItemDiscriminator = this.data.getDiscriminator();
    }
  
    /**
     * @param value value of one of field data
     */
    @com.fasterxml.jackson.annotation.JsonIgnore
    public void setDataInWrapper(Object value) {
      if (value == null) {
        return;
      }
      if (this.data == null) {
        this.data = new OneOfDataWrapper();
      }
      this.data.setValue(value);
      this.$dataItemDiscriminator = this.data.getDiscriminator();
    }
  
    /**
     * Get data in one of possible types :
     * 
    *
  • EMPTY_LIST
  • *
  • List(networking.v4.config.FloatingIp)
  • *
  • com.nutanix.dp1.net.networking.v4.error.ErrorResponse
  • *
  • List(networking.v4.config.FloatingIpProjection)
  • *
* @return Object */ @com.fasterxml.jackson.databind.annotation.JsonSerialize(using = com.nutanix.dp1.net.serializers.NetOneOfSerializer.class) public Object getData() { if (this.data == null) { log.debug("OneOf property data was never set. Returning null..."); return null; } return handleEtag(this.data.getValue(), this.get$reserved()); } @Getter @JsonView({StandardView.class}) protected final Map $reserved; @Getter @JsonView({StandardView.class}) protected final String $objectType; @Getter @JsonView({StandardView.class}) protected final Map $unknownFields; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy