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.IntegerSchema 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.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.common.primitives.Longs;
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.List;
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 AbstractIntegerSchema}.
*
* Use the builder to create immutable instances:
* {@code IntegerSchema.builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Immutable
@CheckReturnValue
public final class IntegerSchema extends AbstractIntegerSchema {
private final TypedSchema.Type type;
private final @Nullable AbstractIntegerSchema.Format format;
private final @Nullable Long minimum;
private final @Nullable Long maximum;
private final @Nullable Long multipleOf;
private final @Nullable Boolean exclusiveMinimum;
private final @Nullable Boolean exclusiveMaximum;
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 final ImmutableList getEnum;
private IntegerSchema(
@Nullable AbstractIntegerSchema.Format format,
@Nullable Long minimum,
@Nullable Long maximum,
@Nullable Long multipleOf,
@Nullable Boolean exclusiveMinimum,
@Nullable Boolean exclusiveMaximum,
@Nullable Boolean nullable,
@Nullable String title,
@Nullable Object getDefault,
@Nullable XmlObject xml,
@Nullable String description,
@Nullable Object example,
ImmutableMap extensions,
ImmutableList getEnum) {
this.format = format;
this.minimum = minimum;
this.maximum = maximum;
this.multipleOf = multipleOf;
this.exclusiveMinimum = exclusiveMinimum;
this.exclusiveMaximum = exclusiveMaximum;
this.nullable = nullable;
this.title = title;
this.getDefault = getDefault;
this.xml = xml;
this.description = description;
this.example = example;
this.extensions = extensions;
this.getEnum = getEnum;
this.type = initShim.getType();
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(IntegerSchema.super.getType(), "type");
typeBuildStage = STAGE_INITIALIZED;
}
return this.type;
}
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 = IntegerSchema.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 IntegerSchema, attribute initializers form cycle" + attributes;
}
}
/**
* @return The computed-at-construction 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 format} attribute
*/
@JsonProperty("format")
@Override
public Optional getFormat() {
return Optional.ofNullable(format);
}
/**
* @return The value of the {@code minimum} attribute
*/
@JsonProperty("minimum")
@Override
public Optional getMinimum() {
return Optional.ofNullable(minimum);
}
/**
* @return The value of the {@code maximum} attribute
*/
@JsonProperty("maximum")
@Override
public Optional getMaximum() {
return Optional.ofNullable(maximum);
}
/**
* @return The value of the {@code multipleOf} attribute
*/
@JsonProperty("multipleOf")
@Override
public Optional getMultipleOf() {
return Optional.ofNullable(multipleOf);
}
/**
* @return The value of the {@code exclusiveMinimum} attribute
*/
@JsonProperty("exclusiveMinimum")
@Override
public Optional getExclusiveMinimum() {
return Optional.ofNullable(exclusiveMinimum);
}
/**
* @return The value of the {@code exclusiveMaximum} attribute
*/
@JsonProperty("exclusiveMaximum")
@Override
public Optional getExclusiveMaximum() {
return Optional.ofNullable(exclusiveMaximum);
}
/**
* @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;
}
/**
* @return The value of the {@code getEnum} attribute
*/
@JsonProperty("enum")
@Override
public ImmutableList getEnum() {
return getEnum;
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getFormat() format} attribute.
* @param value The value for format, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withFormat(@Nullable AbstractIntegerSchema.Format value) {
@Nullable AbstractIntegerSchema.Format newValue = value;
if (this.format == newValue) return this;
return validate(new IntegerSchema(
newValue,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getFormat() format} 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 format
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withFormat(Optional extends AbstractIntegerSchema.Format> optional) {
@Nullable AbstractIntegerSchema.Format value = optional.orElse(null);
if (Objects.equals(this.format, value)) return this;
return validate(new IntegerSchema(
value,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getMinimum() minimum} attribute.
* @param value The value for minimum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMinimum(@Nullable Long value) {
@Nullable Long newValue = value;
if (Objects.equals(this.minimum, newValue)) return this;
return validate(new IntegerSchema(
this.format,
newValue,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getMinimum() minimum} 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 minimum
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMinimum(Optional optional) {
@Nullable Long value = optional.orElse(null);
if (Objects.equals(this.minimum, value)) return this;
return validate(new IntegerSchema(
this.format,
value,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getMaximum() maximum} attribute.
* @param value The value for maximum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMaximum(@Nullable Long value) {
@Nullable Long newValue = value;
if (Objects.equals(this.maximum, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
newValue,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getMaximum() maximum} 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 maximum
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMaximum(Optional optional) {
@Nullable Long value = optional.orElse(null);
if (Objects.equals(this.maximum, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
value,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getMultipleOf() multipleOf} attribute.
* @param value The value for multipleOf, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMultipleOf(@Nullable Long value) {
@Nullable Long newValue = value;
if (Objects.equals(this.multipleOf, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
newValue,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getMultipleOf() multipleOf} 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 multipleOf
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withMultipleOf(Optional optional) {
@Nullable Long value = optional.orElse(null);
if (Objects.equals(this.multipleOf, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
value,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getExclusiveMinimum() exclusiveMinimum} attribute.
* @param value The value for exclusiveMinimum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withExclusiveMinimum(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.exclusiveMinimum, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
newValue,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getExclusiveMinimum() exclusiveMinimum} 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 exclusiveMinimum
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withExclusiveMinimum(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.exclusiveMinimum, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
value,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#getExclusiveMaximum() exclusiveMaximum} attribute.
* @param value The value for exclusiveMaximum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withExclusiveMaximum(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.exclusiveMaximum, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
newValue,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#getExclusiveMaximum() exclusiveMaximum} 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 exclusiveMaximum
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withExclusiveMaximum(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.exclusiveMaximum, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
value,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withNullable(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.nullable, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
newValue,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withNullable(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.nullable, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
value,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withTitle(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.title, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
newValue,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withTitle(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.title, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
value,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withDefault(@Nullable Object value) {
@Nullable Object newValue = value;
if (this.getDefault == newValue) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
newValue,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withDefault(Optional extends Object> optional) {
@Nullable Object value = optional.orElse(null);
if (this.getDefault == value) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
value,
this.xml,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withXml(@Nullable XmlObject value) {
@Nullable XmlObject newValue = value;
if (this.xml == newValue) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
newValue,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withXml(Optional extends XmlObject> optional) {
@Nullable XmlObject value = optional.orElse(null);
if (this.xml == value) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
value,
this.description,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withDescription(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.description, newValue)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
newValue,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
value,
this.example,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractIntegerSchema#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 IntegerSchema withExample(@Nullable Object value) {
@Nullable Object newValue = value;
if (this.example == newValue) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
newValue,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractIntegerSchema#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 IntegerSchema withExample(Optional extends Object> optional) {
@Nullable Object value = optional.orElse(null);
if (this.example == value) return this;
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
value,
this.extensions,
this.getEnum));
}
/**
* Copy the current immutable object by replacing the {@link AbstractIntegerSchema#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 IntegerSchema withExtensions(Map entries) {
if (this.extensions == entries) return this;
ImmutableMap newValue = ImmutableMap.copyOf(entries);
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
newValue,
this.getEnum));
}
/**
* Copy the current immutable object with elements that replace the content of {@link AbstractIntegerSchema#getEnum() enum}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withEnum(long... elements) {
ImmutableList newValue = ImmutableList.copyOf(Longs.asList(elements));
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
newValue));
}
/**
* Copy the current immutable object with elements that replace the content of {@link AbstractIntegerSchema#getEnum() enum}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of getEnum elements to set
* @return A modified copy of {@code this} object
*/
public final IntegerSchema withEnum(Iterable elements) {
if (this.getEnum == elements) return this;
ImmutableList newValue = ImmutableList.copyOf(elements);
return validate(new IntegerSchema(
this.format,
this.minimum,
this.maximum,
this.multipleOf,
this.exclusiveMinimum,
this.exclusiveMaximum,
this.nullable,
this.title,
this.getDefault,
this.xml,
this.description,
this.example,
this.extensions,
newValue));
}
/**
* This instance is equal to all instances of {@code IntegerSchema} 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 IntegerSchema
&& equalTo((IntegerSchema) another);
}
private boolean equalTo(IntegerSchema another) {
return type.equals(another.type)
&& Objects.equals(format, another.format)
&& Objects.equals(minimum, another.minimum)
&& Objects.equals(maximum, another.maximum)
&& Objects.equals(multipleOf, another.multipleOf)
&& Objects.equals(exclusiveMinimum, another.exclusiveMinimum)
&& Objects.equals(exclusiveMaximum, another.exclusiveMaximum)
&& 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
&& getEnum.equals(another.getEnum);
}
/**
* Computes a hash code from attributes: {@code type}, {@code format}, {@code minimum}, {@code maximum}, {@code multipleOf}, {@code exclusiveMinimum}, {@code exclusiveMaximum}, {@code nullable}, {@code title}, {@code getDefault}, {@code xml}, {@code description}, {@code example}, {@code extensions}, {@code referential}, {@code getEnum}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + type.hashCode();
h += (h << 5) + Objects.hashCode(format);
h += (h << 5) + Objects.hashCode(minimum);
h += (h << 5) + Objects.hashCode(maximum);
h += (h << 5) + Objects.hashCode(multipleOf);
h += (h << 5) + Objects.hashCode(exclusiveMinimum);
h += (h << 5) + Objects.hashCode(exclusiveMaximum);
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);
h += (h << 5) + getEnum.hashCode();
return h;
}
/**
* Prints the immutable value {@code IntegerSchema} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("IntegerSchema")
.omitNullValues()
.add("type", type)
.add("format", format)
.add("minimum", minimum)
.add("maximum", maximum)
.add("multipleOf", multipleOf)
.add("exclusiveMinimum", exclusiveMinimum)
.add("exclusiveMaximum", exclusiveMaximum)
.add("nullable", nullable)
.add("title", title)
.add("default", getDefault)
.add("xml", xml)
.add("description", description)
.add("example", example)
.add("extensions", extensions)
.add("referential", referential)
.add("enum", getEnum)
.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 AbstractIntegerSchema {
@Nullable Optional format = Optional.empty();
@Nullable Optional minimum = Optional.empty();
@Nullable Optional maximum = Optional.empty();
@Nullable Optional multipleOf = Optional.empty();
@Nullable Optional exclusiveMinimum = Optional.empty();
@Nullable Optional exclusiveMaximum = Optional.empty();
@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();
@Nullable List getEnum = ImmutableList.of();
final Map extensions = new HashMap();
@JsonProperty("format")
public void setFormat(Optional format) {
this.format = format;
}
@JsonProperty("minimum")
public void setMinimum(Optional minimum) {
this.minimum = minimum;
}
@JsonProperty("maximum")
public void setMaximum(Optional maximum) {
this.maximum = maximum;
}
@JsonProperty("multipleOf")
public void setMultipleOf(Optional multipleOf) {
this.multipleOf = multipleOf;
}
@JsonProperty("exclusiveMinimum")
public void setExclusiveMinimum(Optional exclusiveMinimum) {
this.exclusiveMinimum = exclusiveMinimum;
}
@JsonProperty("exclusiveMaximum")
public void setExclusiveMaximum(Optional exclusiveMaximum) {
this.exclusiveMaximum = exclusiveMaximum;
}
@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;
}
@JsonProperty("enum")
public void setEnum(List getEnum) {
this.getEnum = getEnum;
}
@JsonAnySetter
public void setExtensions(String key, Object value) {
this.extensions.put(key, value);
}
@Override
public TypedSchema.Type getType() { throw new UnsupportedOperationException(); }
@Override
public Optional getFormat() { throw new UnsupportedOperationException(); }
@Override
public Optional getMinimum() { throw new UnsupportedOperationException(); }
@Override
public Optional getMaximum() { throw new UnsupportedOperationException(); }
@Override
public Optional getMultipleOf() { throw new UnsupportedOperationException(); }
@Override
public Optional getExclusiveMinimum() { throw new UnsupportedOperationException(); }
@Override
public Optional getExclusiveMaximum() { 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(); }
@Override
public List getEnum() { 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 IntegerSchema fromJson(Json json) {
IntegerSchema.Builder builder = IntegerSchema.builder();
if (json.format != null) {
builder.setFormat(json.format);
}
if (json.minimum != null) {
builder.setMinimum(json.minimum);
}
if (json.maximum != null) {
builder.setMaximum(json.maximum);
}
if (json.multipleOf != null) {
builder.setMultipleOf(json.multipleOf);
}
if (json.exclusiveMinimum != null) {
builder.setExclusiveMinimum(json.exclusiveMinimum);
}
if (json.exclusiveMaximum != null) {
builder.setExclusiveMaximum(json.exclusiveMaximum);
}
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);
}
if (json.getEnum != null) {
builder.addAllEnum(json.getEnum);
}
return builder.build();
}
private static IntegerSchema validate(IntegerSchema instance) {
instance = (IntegerSchema) instance.normalizeExtensions();
return instance;
}
/**
* Creates an immutable copy of a {@link AbstractIntegerSchema} 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 IntegerSchema instance
*/
public static IntegerSchema copyOf(AbstractIntegerSchema instance) {
if (instance instanceof IntegerSchema) {
return (IntegerSchema) instance;
}
return IntegerSchema.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link IntegerSchema IntegerSchema}.
* @return A new IntegerSchema builder
*/
public static IntegerSchema.Builder builder() {
return new IntegerSchema.Builder();
}
/**
* Builds instances of type {@link IntegerSchema IntegerSchema}.
* 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 AbstractIntegerSchema.Format format;
private @Nullable Long minimum;
private @Nullable Long maximum;
private @Nullable Long multipleOf;
private @Nullable Boolean exclusiveMinimum;
private @Nullable Boolean exclusiveMaximum;
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 ImmutableList.Builder getEnum = ImmutableList.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.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.schemas.AbstractIntegerSchema} 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(AbstractIntegerSchema 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.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) {
if (object instanceof WithSingleExample) {
WithSingleExample instance = (WithSingleExample) object;
Optional exampleOptional = instance.getExample();
if (exampleOptional.isPresent()) {
setExample(exampleOptional);
}
}
if (object instanceof Extensible) {
Extensible instance = (Extensible) object;
putAllExtensions(instance.getExtensions());
}
if (object instanceof AbstractIntegerSchema) {
AbstractIntegerSchema instance = (AbstractIntegerSchema) object;
Optional multipleOfOptional = instance.getMultipleOf();
if (multipleOfOptional.isPresent()) {
setMultipleOf(multipleOfOptional);
}
Optional exclusiveMaximumOptional = instance.getExclusiveMaximum();
if (exclusiveMaximumOptional.isPresent()) {
setExclusiveMaximum(exclusiveMaximumOptional);
}
Optional formatOptional = instance.getFormat();
if (formatOptional.isPresent()) {
setFormat(formatOptional);
}
addAllEnum(instance.getEnum());
Optional maximumOptional = instance.getMaximum();
if (maximumOptional.isPresent()) {
setMaximum(maximumOptional);
}
Optional exclusiveMinimumOptional = instance.getExclusiveMinimum();
if (exclusiveMinimumOptional.isPresent()) {
setExclusiveMinimum(exclusiveMinimumOptional);
}
Optional minimumOptional = instance.getMinimum();
if (minimumOptional.isPresent()) {
setMinimum(minimumOptional);
}
}
if (object instanceof Describable) {
Describable instance = (Describable) object;
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
setDescription(descriptionOptional);
}
}
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 optional value {@link AbstractIntegerSchema#getFormat() format} to format.
* @param format The value for format, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setFormat(@Nullable AbstractIntegerSchema.Format format) {
this.format = format;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getFormat() format} to format.
* @param format The value for format
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setFormat(Optional extends AbstractIntegerSchema.Format> format) {
this.format = format.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMinimum() minimum} to minimum.
* @param minimum The value for minimum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMinimum(@Nullable Long minimum) {
this.minimum = minimum;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMinimum() minimum} to minimum.
* @param minimum The value for minimum
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMinimum(Optional minimum) {
this.minimum = minimum.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMaximum() maximum} to maximum.
* @param maximum The value for maximum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMaximum(@Nullable Long maximum) {
this.maximum = maximum;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMaximum() maximum} to maximum.
* @param maximum The value for maximum
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMaximum(Optional maximum) {
this.maximum = maximum.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMultipleOf() multipleOf} to multipleOf.
* @param multipleOf The value for multipleOf, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMultipleOf(@Nullable Long multipleOf) {
this.multipleOf = multipleOf;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getMultipleOf() multipleOf} to multipleOf.
* @param multipleOf The value for multipleOf
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setMultipleOf(Optional multipleOf) {
this.multipleOf = multipleOf.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getExclusiveMinimum() exclusiveMinimum} to exclusiveMinimum.
* @param exclusiveMinimum The value for exclusiveMinimum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExclusiveMinimum(@Nullable Boolean exclusiveMinimum) {
this.exclusiveMinimum = exclusiveMinimum;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getExclusiveMinimum() exclusiveMinimum} to exclusiveMinimum.
* @param exclusiveMinimum The value for exclusiveMinimum
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExclusiveMinimum(Optional exclusiveMinimum) {
this.exclusiveMinimum = exclusiveMinimum.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getExclusiveMaximum() exclusiveMaximum} to exclusiveMaximum.
* @param exclusiveMaximum The value for exclusiveMaximum, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExclusiveMaximum(@Nullable Boolean exclusiveMaximum) {
this.exclusiveMaximum = exclusiveMaximum;
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#getExclusiveMaximum() exclusiveMaximum} to exclusiveMaximum.
* @param exclusiveMaximum The value for exclusiveMaximum
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setExclusiveMaximum(Optional exclusiveMaximum) {
this.exclusiveMaximum = exclusiveMaximum.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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 AbstractIntegerSchema#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;
}
/**
* Adds one element to {@link AbstractIntegerSchema#getEnum() enum} list.
* @param element A getEnum element
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addEnum(long element) {
this.getEnum.add(element);
return this;
}
/**
* Adds elements to {@link AbstractIntegerSchema#getEnum() enum} list.
* @param elements An array of getEnum elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addEnum(long... elements) {
this.getEnum.addAll(Longs.asList(elements));
return this;
}
/**
* Sets or replaces all elements for {@link AbstractIntegerSchema#getEnum() enum} list.
* @param elements An iterable of getEnum elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder setEnum(Iterable elements) {
this.getEnum = ImmutableList.builder();
return addAllEnum(elements);
}
/**
* Adds elements to {@link AbstractIntegerSchema#getEnum() enum} list.
* @param elements An iterable of getEnum elements
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final Builder addAllEnum(Iterable elements) {
this.getEnum.addAll(elements);
return this;
}
/**
* Builds a new {@link IntegerSchema IntegerSchema}.
* @return An immutable instance of IntegerSchema
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public IntegerSchema build() {
return IntegerSchema.validate(new IntegerSchema(
format,
minimum,
maximum,
multipleOf,
exclusiveMinimum,
exclusiveMaximum,
nullable,
title,
getDefault,
xml,
description,
example,
extensions.build(),
getEnum.build()));
}
}
}