com.nutanix.dp1.net.common.v1.config.KVPair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of networking-java-client Show documentation
Show all versions of networking-java-client Show documentation
Manage networking configuration on Nutanix clusters, including AHV and advanced networking.
/*
* Generated file ..
*
* Product version: 4.0.1-alpha-1
*
* Part of the Nutanix Networking Versioned APIs
*
* (c) 2023 Nutanix Inc. All rights reserved
*
*/
package com.nutanix.dp1.net.common.v1.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.*;
/**
* A map describing a set of keys and their corresponding values.
*
*/
@Data
@lombok.extern.slf4j.Slf4j
public class KVPair implements java.io.Serializable, NetObjectTypeTypedObject {
public KVPair() {
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 = "KVPairBuilder")
public KVPair(String name, Object value) {
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.setName(name);
this.setValueInWrapper(value);
}
protected String initialize$objectType() {
return "common.v1.config.KVPair";
}
protected String initialize$fqObjectType() {
return "common.v1.r0.a3.config.KVPair";
}
@JsonAnySetter
private void setUndeserializedFields(String name, String value) {
$unknownFields.put(name, value);
}
/**
* The key of this key-value pair
*/
@JsonProperty("name")
public String name = null;
@Getter
private String $valueItemDiscriminator = null;
@Data
@com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = OneOfValueWrapper.OneOfValueWrapperJsonDeserializer.class)
public static class OneOfValueWrapper {
public OneOfValueWrapper() {
}
public OneOfValueWrapper(String data) {
this.oneOfType1002 = data;
this.discriminator = "String";
this.$objectType = "String";
}
public OneOfValueWrapper(Integer data) {
this.oneOfType1003 = data;
this.discriminator = "Integer";
this.$objectType = "Integer";
}
@com.nutanix.dp1.net.annotations.NetJsonDeserializer
private static class OneOfValueWrapperJsonDeserializer 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_TYPE1002 = TYPE_FACTORY.constructType(String.class);
private static final com.fasterxml.jackson.databind.JavaType ONE_OF_TYPE1003 = TYPE_FACTORY.constructType(Integer.class);
public OneOfValueWrapperJsonDeserializer() {
super(TYPE_FACTORY.constructType(OneOfValueWrapper.class));
}
@Override
protected void setDataObject(OneOfValueWrapper oneOfObject, Object nestedObject) {
if (oneOfObject == null) {
throw new IllegalArgumentException("Instance of OneOfValueWrapper provided is null");
}
if(ONE_OF_TYPE1002.getRawClass().isAssignableFrom(nestedObject.getClass())) {
oneOfObject.setValue(nestedObject);
}
else if(ONE_OF_TYPE1003.getRawClass().isAssignableFrom(nestedObject.getClass())) {
oneOfObject.setValue(nestedObject);
}
else {
throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfValueWrapper:" + 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 String oneOfType1002;
@com.fasterxml.jackson.annotation.JsonIgnore
@lombok.Getter(lombok.AccessLevel.NONE)
@lombok.Setter(lombok.AccessLevel.NONE)
private Integer oneOfType1003;
@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("String".equals(this.discriminator)) {
return this.oneOfType1002;
}
if("Integer".equals(this.discriminator)) {
return this.oneOfType1003;
}
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(String.class.getName().equals(value.getClass().getName())) {
this.oneOfType1002 = (String) value;
this.discriminator = "String";
this.$objectType = "String";
return;
}
if(Integer.class.getName().equals(value.getClass().getName())) {
this.oneOfType1003 = (Integer) value;
this.discriminator = "Integer";
this.$objectType = "Integer";
return;
}
throw new IllegalArgumentException("Attempting to set unsupported object type in OneOfValueWrapper:" + value.getClass().getName());
}
}
private OneOfValueWrapper value = null;
/**
* @deprecated
* @param value one of wrapper instance
*/
public void setValue(OneOfValueWrapper value) {
log.warn("Deprecating this method, please use setDataInWrapper instead");
if (value == null) {
return;
}
this.value = value;
this.$valueItemDiscriminator = this.value.getDiscriminator();
}
/**
* @param value value of one of field value
*/
@com.fasterxml.jackson.annotation.JsonIgnore
public void setValueInWrapper(Object value) {
if (value == null) {
return;
}
if (this.value == null) {
this.value = new OneOfValueWrapper();
}
this.value.setValue(value);
this.$valueItemDiscriminator = this.value.getDiscriminator();
}
/**
* Get value in one of possible types :
*
* - String
* - Integer
*
* @return Object
*/
@com.fasterxml.jackson.databind.annotation.JsonSerialize(using = com.nutanix.dp1.net.serializers.NetOneOfSerializer.class)
public Object getValue() {
if (this.value == null) {
log.debug("OneOf property value was never set. Returning null...");
return null;
}
return this.value.getValue();
}
@Getter
@JsonView({StandardView.class})
@JsonProperty("$reserved")
protected final Map $reserved;
@Getter
@JsonView({StandardView.class})
@JsonProperty("$objectType")
protected final String $objectType;
@Getter
@JsonView({StandardView.class})
@JsonProperty("$unknownFields")
protected final Map $unknownFields;
}