Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
io.github.emm035.openapi.immutables.v3.schemas.BooleanSchema Maven / Gradle / Ivy
Go to download
An implementation of the OpenAPI 3.0 specification with Java Immutables
package io.github.emm035.openapi.immutables.v3.schemas;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.github.emm035.openapi.immutables.v3.shared.Describable;
import io.github.emm035.openapi.immutables.v3.shared.Extensible;
import io.github.emm035.openapi.immutables.v3.shared.WithSingleExample;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link AbstractBooleanSchema}.
*
* Use the builder to create immutable instances:
* {@code BooleanSchema.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Immutable
@CheckReturnValue
public final class BooleanSchema extends AbstractBooleanSchema {
private final TypedSchema.Type type;
private final @Nullable Boolean nullable;
private final @Nullable String title;
private final @Nullable Object getDefault;
private final @Nullable XmlObject xml;
private final @Nullable String description;
private final @Nullable Object example;
private final ImmutableMap extensions;
private final boolean referential;
private BooleanSchema(BooleanSchema.Builder builder) {
this.nullable = builder.nullable;
this.title = builder.title;
this.getDefault = builder.getDefault;
this.xml = builder.xml;
this.description = builder.description;
this.example = builder.example;
this.extensions = builder.extensions.build();
if (builder.type != null) {
initShim.setType(builder.type);
}
this.type = initShim.getType();
this.referential = initShim.isReferential();
this.initShim = null;
}
private BooleanSchema(
TypedSchema.Type type,
@Nullable Boolean nullable,
@Nullable String title,
@Nullable Object getDefault,
@Nullable XmlObject xml,
@Nullable String description,
@Nullable Object example,
ImmutableMap extensions) {
this.type = type;
this.nullable = nullable;
this.title = title;
this.getDefault = getDefault;
this.xml = xml;
this.description = description;
this.example = example;
this.extensions = extensions;
initShim.setType(this.type);
this.referential = initShim.isReferential();
this.initShim = null;
}
private static final int STAGE_INITIALIZING = -1;
private static final int STAGE_UNINITIALIZED = 0;
private static final int STAGE_INITIALIZED = 1;
private transient volatile InitShim initShim = new InitShim();
private final class InitShim {
private TypedSchema.Type type;
private int typeBuildStage;
TypedSchema.Type getType() {
if (typeBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (typeBuildStage == STAGE_UNINITIALIZED) {
typeBuildStage = STAGE_INITIALIZING;
this.type = Objects.requireNonNull(BooleanSchema.super.getType(), "type");
typeBuildStage = STAGE_INITIALIZED;
}
return this.type;
}
void setType(TypedSchema.Type type) {
this.type = type;
typeBuildStage = STAGE_INITIALIZED;
}
private boolean referential;
private int referentialBuildStage;
boolean isReferential() {
if (referentialBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (referentialBuildStage == STAGE_UNINITIALIZED) {
referentialBuildStage = STAGE_INITIALIZING;
this.referential = BooleanSchema.super.isReferential();
referentialBuildStage = STAGE_INITIALIZED;
}
return this.referential;
}
private String formatInitCycleMessage() {
ArrayList attributes = Lists.newArrayList();
if (typeBuildStage == STAGE_INITIALIZING) attributes.add("type");
if (referentialBuildStage == STAGE_INITIALIZING) attributes.add("referential");
return "Cannot build BooleanSchema, attribute initializers form cycle" + attributes;
}
}
/**
* @return The value of the {@code type} attribute
*/
@JsonProperty("type")
@Override
public TypedSchema.Type getType() {
InitShim shim = this.initShim;
return shim != null
? shim.getType()
: this.type;
}
/**
* @return The value of the {@code nullable} attribute
*/
@JsonProperty("nullable")
@Override
public Optional isNullable() {
return Optional.ofNullable(nullable);
}
/**
* @return The value of the {@code title} attribute
*/
@JsonProperty("title")
@Override
public Optional getTitle() {
return Optional.ofNullable(title);
}
/**
* @return The value of the {@code getDefault} attribute
*/
@JsonProperty("default")
@Override
public Optional getDefault() {
return Optional.ofNullable(getDefault);
}
/**
* @return The value of the {@code xml} attribute
*/
@JsonProperty("xml")
@Override
public Optional getXml() {
return Optional.ofNullable(xml);
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty("description")
@Override
public Optional getDescription() {
return Optional.ofNullable(description);
}
/**
* @return The value of the {@code example} attribute
*/
@JsonProperty("example")
@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.ALWAYS)
@Override
public Optional getExample() {
return Optional.ofNullable(example);
}
/**
* @return The value of the {@code extensions} attribute
*/
@JsonProperty("extensions")
@JsonAnyGetter
@Override
public ImmutableMap getExtensions() {
return extensions;
}
/**
* @return The computed-at-construction value of the {@code referential} attribute
*/
@JsonProperty("referential")
@JsonIgnore
@Override
public boolean isReferential() {
InitShim shim = this.initShim;
return shim != null
? shim.isReferential()
: this.referential;
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractBooleanSchema#getType() type} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for type
* @return A modified copy of the {@code this} object
*/
public final BooleanSchema withType(TypedSchema.Type value) {
if (this.type == value) return this;
TypedSchema.Type newValue = Objects.requireNonNull(value, "type");
return validate(new BooleanSchema(
newValue,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#isNullable() nullable} attribute.
* @param value The value for nullable, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withNullable(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.nullable, newValue)) return this;
return validate(new BooleanSchema(
this.type,
newValue,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#isNullable() nullable} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for nullable
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withNullable(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.nullable, value)) return this;
return validate(new BooleanSchema(
this.type,
value,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#getTitle() title} attribute.
* @param value The value for title, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withTitle(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.title, newValue)) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
newValue,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#getTitle() title} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for title
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withTitle(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.title, value)) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
value,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#getDefault() default} attribute.
* @param value The value for getDefault, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withDefault(@Nullable Object value) {
@Nullable Object newValue = value;
if (this.getDefault == newValue) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
newValue,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#getDefault() default} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for getDefault
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withDefault(Optional extends Object> optional) {
@Nullable Object value = optional.orElse(null);
if (this.getDefault == value) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
value,
this.xml,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#getXml() xml} attribute.
* @param value The value for xml, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withXml(@Nullable XmlObject value) {
@Nullable XmlObject newValue = value;
if (this.xml == newValue) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
newValue,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#getXml() xml} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for xml
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withXml(Optional extends XmlObject> optional) {
@Nullable XmlObject value = optional.orElse(null);
if (this.xml == value) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
value,
this.description,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#getDescription() description} attribute.
* @param value The value for description, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withDescription(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.description, newValue)) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
this.xml,
newValue,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#getDescription() description} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for description
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
this.xml,
value,
this.example,
this.extensions));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractBooleanSchema#getExample() example} attribute.
* @param value The value for example, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withExample(@Nullable Object value) {
@Nullable Object newValue = value;
if (this.example == newValue) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
newValue,
this.extensions));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractBooleanSchema#getExample() example} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for example
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withExample(Optional extends Object> optional) {
@Nullable Object value = optional.orElse(null);
if (this.example == value) return this;
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
value,
this.extensions));
}
/**
* Copy the current immutable object by replacing the {@link AbstractBooleanSchema#getExtensions() extensions} map with the specified map.
* Nulls are not permitted as keys or values.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param entries The entries to be added to the extensions map
* @return A modified copy of {@code this} object
*/
public final BooleanSchema withExtensions(Map entries) {
if (this.extensions == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return validate(new BooleanSchema(
this.type,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
newValue));
}
/**
* This instance is equal to all instances of {@code BooleanSchema} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(@Nullable Object another) {
if (this == another) return true;
return another instanceof BooleanSchema
&& equalTo((BooleanSchema) another);
}
private boolean equalTo(BooleanSchema another) {
return type.equals(another.type)
&& Objects.equals(nullable, another.nullable)
&& Objects.equals(title, another.title)
&& Objects.equals(getDefault, another.getDefault)
&& Objects.equals(xml, another.xml)
&& Objects.equals(description, another.description)
&& Objects.equals(example, another.example)
&& extensions.equals(another.extensions)
&& referential == another.referential;
}
/**
* Computes a hash code from attributes: {@code type}, {@code nullable}, {@code title}, {@code getDefault}, {@code xml}, {@code description}, {@code example}, {@code extensions}, {@code referential}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + type.hashCode();
h += (h << 5) + Objects.hashCode(nullable);
h += (h << 5) + Objects.hashCode(title);
h += (h << 5) + Objects.hashCode(getDefault);
h += (h << 5) + Objects.hashCode(xml);
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + Objects.hashCode(example);
h += (h << 5) + extensions.hashCode();
h += (h << 5) + Booleans.hashCode(referential);
return h;
}
/**
* Prints the immutable value {@code BooleanSchema} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("BooleanSchema")
.omitNullValues()
.add("type", type)
.add("nullable", nullable)
.add("title", title)
.add("default", getDefault)
.add("xml", xml)
.add("description", description)
.add("example", example)
.add("extensions", extensions)
.add("referential", referential)
.toString();
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson -binding infrastructure
*/
@Deprecated
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends AbstractBooleanSchema {
@Nullable TypedSchema.Type type;
@Nullable Optional nullable = Optional.empty();
@Nullable Optional title = Optional.empty();
@Nullable Optional getDefault = Optional.empty();
@Nullable Optional xml = Optional.empty();
@Nullable Optional description = Optional.empty();
@Nullable Optional example = Optional.empty();
final Map extensions = new HashMap();
@JsonProperty("type")
public void setType(TypedSchema.Type type) {
this.type = type;
}
@JsonProperty("nullable")
public void setNullable(Optional nullable) {
this.nullable = nullable;
}
@JsonProperty("title")
public void setTitle(Optional title) {
this.title = title;
}
@JsonProperty("default")
public void setDefault(Optional getDefault) {
this.getDefault = getDefault;
}
@JsonProperty("xml")
public void setXml(Optional xml) {
this.xml = xml;
}
@JsonProperty("description")
public void setDescription(Optional description) {
this.description = description;
}
@JsonProperty("example")
@JsonInclude(value = JsonInclude.Include.NON_ABSENT, content = JsonInclude.Include.ALWAYS)
public void setExample(Optional example) {
this.example = example;
}
@JsonAnySetter
public void setExtensions(String key, Object value) {
this.extensions.put(key, value);
}
@Override
public TypedSchema.Type getType() { throw new UnsupportedOperationException(); }
@Override
public Optional isNullable() { throw new UnsupportedOperationException(); }
@Override
public Optional getTitle() { throw new UnsupportedOperationException(); }
@Override
public Optional getDefault() { throw new UnsupportedOperationException(); }
@Override
public Optional getXml() { throw new UnsupportedOperationException(); }
@Override
public Optional getDescription() { throw new UnsupportedOperationException(); }
@Override
public Optional getExample() { throw new UnsupportedOperationException(); }
@Override
public Map getExtensions() { throw new UnsupportedOperationException(); }
@Override
public boolean isReferential() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson -binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static BooleanSchema fromJson(Json json) {
BooleanSchema.Builder builder = BooleanSchema.builder();
if (json.type != null) {
builder.setType(json.type);
}
if (json.nullable != null) {
builder.setNullable(json.nullable);
}
if (json.title != null) {
builder.setTitle(json.title);
}
if (json.getDefault != null) {
builder.setDefault(json.getDefault);
}
if (json.xml != null) {
builder.setXml(json.xml);
}
if (json.description != null) {
builder.setDescription(json.description);
}
if (json.example != null) {
builder.setExample(json.example);
}
if (json.extensions != null) {
builder.putAllExtensions(json.extensions);
}
return builder.build();
}
private static BooleanSchema validate(BooleanSchema instance) {
instance = (BooleanSchema) instance.normalizeExtensions();
return instance;
}
/**
* Creates an immutable copy of a {@link AbstractBooleanSchema} value.
* Uses accessors to get values to initialize the new immutable instance.
* If an instance is already immutable, it is returned as is.
* @param instance The instance to copy
* @return A copied immutable BooleanSchema instance
*/
public static BooleanSchema copyOf(AbstractBooleanSchema instance) {
if (instance instanceof BooleanSchema) {
return (BooleanSchema) instance;
}
return BooleanSchema.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link BooleanSchema BooleanSchema}.
* @return A new BooleanSchema builder
*/
public static BooleanSchema.Builder builder() {
return new BooleanSchema.Builder();
}
/**
* Builds instances of type {@link BooleanSchema BooleanSchema}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@NotThreadSafe
public static final class Builder {
private @Nullable TypedSchema.Type type;
private @Nullable Boolean nullable;
private @Nullable String title;
private @Nullable Object getDefault;
private @Nullable XmlObject xml;
private @Nullable String description;
private @Nullable Object example;
private ImmutableMap.Builder extensions = ImmutableMap.builder();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.shared.WithSingleExample} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(WithSingleExample instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.schemas.AbstractBooleanSchema} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(AbstractBooleanSchema instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.shared.Extensible} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(Extensible instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.shared.Describable} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(Describable instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.schemas.TypedSchema} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(TypedSchema instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code io.github.emm035.openapi.immutables.v3.schemas.Schema} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder from(Schema instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return this;
}
private void from(Object object) {
long bits = 0;
if (object instanceof WithSingleExample) {
WithSingleExample instance = (WithSingleExample) object;
Optional exampleOptional = instance.getExample();
if (exampleOptional.isPresent()) {
setExample(exampleOptional);
}
}
if (object instanceof AbstractBooleanSchema) {
AbstractBooleanSchema instance = (AbstractBooleanSchema) object;
if ((bits & 0x1L) == 0) {
setType(instance.getType());
bits |= 0x1L;
}
}
if (object instanceof Extensible) {
Extensible instance = (Extensible) object;
putAllExtensions(instance.getExtensions());
}
if (object instanceof Describable) {
Describable instance = (Describable) object;
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
setDescription(descriptionOptional);
}
}
if (object instanceof TypedSchema) {
TypedSchema instance = (TypedSchema) object;
if ((bits & 0x1L) == 0) {
setType(instance.getType());
bits |= 0x1L;
}
}
if (object instanceof Schema) {
Schema instance = (Schema) object;
Optional getDefaultOptional = instance.getDefault();
if (getDefaultOptional.isPresent()) {
setDefault(getDefaultOptional);
}
Optional nullableOptional = instance.isNullable();
if (nullableOptional.isPresent()) {
setNullable(nullableOptional);
}
Optional titleOptional = instance.getTitle();
if (titleOptional.isPresent()) {
setTitle(titleOptional);
}
Optional xmlOptional = instance.getXml();
if (xmlOptional.isPresent()) {
setXml(xmlOptional);
}
}
}
/**
* Initializes the value for the {@link AbstractBooleanSchema#getType() type} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link AbstractBooleanSchema#getType() type}.
* @param type The value for type
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setType(TypedSchema.Type type) {
this.type = Objects.requireNonNull(type, "type");
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#isNullable() nullable} to nullable.
* @param nullable The value for nullable, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setNullable(@Nullable Boolean nullable) {
this.nullable = nullable;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#isNullable() nullable} to nullable.
* @param nullable The value for nullable
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setNullable(Optional nullable) {
this.nullable = nullable.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getTitle() title} to title.
* @param title The value for title, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setTitle(@Nullable String title) {
this.title = title;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getTitle() title} to title.
* @param title The value for title
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setTitle(Optional title) {
this.title = title.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getDefault() default} to getDefault.
* @param getDefault The value for getDefault, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setDefault(@Nullable Object getDefault) {
this.getDefault = getDefault;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getDefault() default} to getDefault.
* @param getDefault The value for getDefault
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setDefault(Optional extends Object> getDefault) {
this.getDefault = getDefault.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getXml() xml} to xml.
* @param xml The value for xml, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setXml(@Nullable XmlObject xml) {
this.xml = xml;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getXml() xml} to xml.
* @param xml The value for xml
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setXml(Optional extends XmlObject> xml) {
this.xml = xml.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getDescription() description} to description.
* @param description The value for description, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setDescription(@Nullable String description) {
this.description = description;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setDescription(Optional description) {
this.description = description.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getExample() example} to example.
* @param example The value for example, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExample(@Nullable Object example) {
this.example = example;
return this;
}
/**
* Initializes the optional value {@link AbstractBooleanSchema#getExample() example} to example.
* @param example The value for example
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExample(Optional extends Object> example) {
this.example = example.orElse(null);
return this;
}
/**
* Put one entry to the {@link AbstractBooleanSchema#getExtensions() extensions} map.
* @param key The key in the extensions map
* @param value The associated value in the extensions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonAnySetter
public final Builder putExtensions(String key, Object value) {
this.extensions.put(key, value);
return this;
}
/**
* Put one entry to the {@link AbstractBooleanSchema#getExtensions() extensions} map. Nulls are not permitted
* @param entry The key and value entry
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putExtensions(Map.Entry entry) {
this.extensions.put(entry);
return this;
}
/**
* Sets or replaces all mappings from the specified map as entries for the {@link AbstractBooleanSchema#getExtensions() extensions} map. Nulls are not permitted
* @param extensions The entries that will be added to the extensions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExtensions(Map extensions) {
this.extensions = ImmutableMap.builder();
return putAllExtensions(extensions);
}
/**
* Put all mappings from the specified map as entries to {@link AbstractBooleanSchema#getExtensions() extensions} map. Nulls are not permitted
* @param extensions The entries that will be added to the extensions map
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder putAllExtensions(Map extensions) {
this.extensions.putAll(extensions);
return this;
}
/**
* Builds a new {@link BooleanSchema BooleanSchema}.
* @return An immutable instance of BooleanSchema
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public BooleanSchema build() {
return BooleanSchema.validate(new BooleanSchema(this));
}
}
}