
io.syndesis.integration.component.proxy.ImmutableComponent Maven / Gradle / Ivy
package io.syndesis.integration.component.proxy;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.immutables.value.Generated;
/**
* Immutable implementation of {@link ComponentDefinition.Component}.
*
* Use the builder to create immutable instances:
* {@code new ImmutableComponent.Builder()}.
*/
@Generated(from = "ComponentDefinition.Component", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
public final class ImmutableComponent
implements ComponentDefinition.Component {
private final String kind;
private final String scheme;
private final String syntax;
private final String title;
private final String description;
private final String label;
private final String deprecated;
private final String consumerOnly;
private final String producerOnly;
private final String javaType;
private final String groupId;
private final String artifactId;
private final String version;
private final String alternativeSyntax;
private final String alternativeSchemes;
private final String firstVersion;
private ImmutableComponent(
String kind,
String scheme,
String syntax,
String title,
String description,
String label,
String deprecated,
String consumerOnly,
String producerOnly,
String javaType,
String groupId,
String artifactId,
String version,
String alternativeSyntax,
String alternativeSchemes,
String firstVersion) {
this.kind = kind;
this.scheme = scheme;
this.syntax = syntax;
this.title = title;
this.description = description;
this.label = label;
this.deprecated = deprecated;
this.consumerOnly = consumerOnly;
this.producerOnly = producerOnly;
this.javaType = javaType;
this.groupId = groupId;
this.artifactId = artifactId;
this.version = version;
this.alternativeSyntax = alternativeSyntax;
this.alternativeSchemes = alternativeSchemes;
this.firstVersion = firstVersion;
}
/**
* @return The value of the {@code kind} attribute
*/
@JsonProperty("kind")
@Override
public String getKind() {
return kind;
}
/**
* @return The value of the {@code scheme} attribute
*/
@JsonProperty("scheme")
@Override
public String getScheme() {
return scheme;
}
/**
* @return The value of the {@code syntax} attribute
*/
@JsonProperty("syntax")
@Override
public String getSyntax() {
return syntax;
}
/**
* @return The value of the {@code title} attribute
*/
@JsonProperty("title")
@Override
public String getTitle() {
return title;
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty("description")
@Override
public String getDescription() {
return description;
}
/**
* @return The value of the {@code label} attribute
*/
@JsonProperty("label")
@Override
public String getLabel() {
return label;
}
/**
* @return The value of the {@code deprecated} attribute
*/
@JsonProperty("deprecated")
@Override
public String getDeprecated() {
return deprecated;
}
/**
* @return The value of the {@code consumerOnly} attribute
*/
@JsonProperty("consumerOnly")
@Override
public String getConsumerOnly() {
return consumerOnly;
}
/**
* @return The value of the {@code producerOnly} attribute
*/
@JsonProperty("producerOnly")
@Override
public String getProducerOnly() {
return producerOnly;
}
/**
* @return The value of the {@code javaType} attribute
*/
@JsonProperty("javaType")
@Override
public String getJavaType() {
return javaType;
}
/**
* @return The value of the {@code groupId} attribute
*/
@JsonProperty("groupId")
@Override
public String getGroupId() {
return groupId;
}
/**
* @return The value of the {@code artifactId} attribute
*/
@JsonProperty("artifactId")
@Override
public String getArtifactId() {
return artifactId;
}
/**
* @return The value of the {@code version} attribute
*/
@JsonProperty("version")
@Override
public String getVersion() {
return version;
}
/**
* @return The value of the {@code alternativeSyntax} attribute
*/
@JsonProperty("alternativeSyntax")
@Override
public Optional getAlternativeSyntax() {
return Optional.ofNullable(alternativeSyntax);
}
/**
* @return The value of the {@code alternativeSchemes} attribute
*/
@JsonProperty("alternativeSchemes")
@Override
public Optional getAlternativeSchemes() {
return Optional.ofNullable(alternativeSchemes);
}
/**
* @return The value of the {@code firstVersion} attribute
*/
@JsonProperty("firstVersion")
@Override
public Optional getFirstVersion() {
return Optional.ofNullable(firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getKind() kind} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for kind
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withKind(String value) {
String newValue = Objects.requireNonNull(value, "kind");
if (this.kind.equals(newValue)) return this;
return new ImmutableComponent(
newValue,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getScheme() scheme} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scheme
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withScheme(String value) {
String newValue = Objects.requireNonNull(value, "scheme");
if (this.scheme.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
newValue,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getSyntax() syntax} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for syntax
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withSyntax(String value) {
String newValue = Objects.requireNonNull(value, "syntax");
if (this.syntax.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
newValue,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getTitle() title} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for title
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withTitle(String value) {
String newValue = Objects.requireNonNull(value, "title");
if (this.title.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
newValue,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getDescription() description} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for description
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withDescription(String value) {
String newValue = Objects.requireNonNull(value, "description");
if (this.description.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
newValue,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getLabel() label} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for label
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withLabel(String value) {
String newValue = Objects.requireNonNull(value, "label");
if (this.label.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
newValue,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getDeprecated() deprecated} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for deprecated
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withDeprecated(String value) {
String newValue = Objects.requireNonNull(value, "deprecated");
if (this.deprecated.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
newValue,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getConsumerOnly() consumerOnly} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for consumerOnly
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withConsumerOnly(String value) {
String newValue = Objects.requireNonNull(value, "consumerOnly");
if (this.consumerOnly.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
newValue,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getProducerOnly() producerOnly} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for producerOnly
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withProducerOnly(String value) {
String newValue = Objects.requireNonNull(value, "producerOnly");
if (this.producerOnly.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
newValue,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getJavaType() javaType} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for javaType
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withJavaType(String value) {
String newValue = Objects.requireNonNull(value, "javaType");
if (this.javaType.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
newValue,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getGroupId() groupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for groupId
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withGroupId(String value) {
String newValue = Objects.requireNonNull(value, "groupId");
if (this.groupId.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
newValue,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getArtifactId() artifactId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for artifactId
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withArtifactId(String value) {
String newValue = Objects.requireNonNull(value, "artifactId");
if (this.artifactId.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
newValue,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a value for the {@link ComponentDefinition.Component#getVersion() version} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for version
* @return A modified copy of the {@code this} object
*/
public final ImmutableComponent withVersion(String value) {
String newValue = Objects.requireNonNull(value, "version");
if (this.version.equals(newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
newValue,
this.alternativeSyntax,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ComponentDefinition.Component#getAlternativeSyntax() alternativeSyntax} attribute.
* @param value The value for alternativeSyntax
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withAlternativeSyntax(String value) {
String newValue = Objects.requireNonNull(value, "alternativeSyntax");
if (Objects.equals(this.alternativeSyntax, newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
newValue,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ComponentDefinition.Component#getAlternativeSyntax() alternativeSyntax} 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 alternativeSyntax
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withAlternativeSyntax(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.alternativeSyntax, value)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
value,
this.alternativeSchemes,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ComponentDefinition.Component#getAlternativeSchemes() alternativeSchemes} attribute.
* @param value The value for alternativeSchemes
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withAlternativeSchemes(String value) {
String newValue = Objects.requireNonNull(value, "alternativeSchemes");
if (Objects.equals(this.alternativeSchemes, newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
newValue,
this.firstVersion);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ComponentDefinition.Component#getAlternativeSchemes() alternativeSchemes} 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 alternativeSchemes
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withAlternativeSchemes(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.alternativeSchemes, value)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
value,
this.firstVersion);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link ComponentDefinition.Component#getFirstVersion() firstVersion} attribute.
* @param value The value for firstVersion
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withFirstVersion(String value) {
String newValue = Objects.requireNonNull(value, "firstVersion");
if (Objects.equals(this.firstVersion, newValue)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link ComponentDefinition.Component#getFirstVersion() firstVersion} 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 firstVersion
* @return A modified copy of {@code this} object
*/
public final ImmutableComponent withFirstVersion(Optional optional) {
String value = optional.orElse(null);
if (Objects.equals(this.firstVersion, value)) return this;
return new ImmutableComponent(
this.kind,
this.scheme,
this.syntax,
this.title,
this.description,
this.label,
this.deprecated,
this.consumerOnly,
this.producerOnly,
this.javaType,
this.groupId,
this.artifactId,
this.version,
this.alternativeSyntax,
this.alternativeSchemes,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableComponent} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
return another instanceof ImmutableComponent
&& equalTo((ImmutableComponent) another);
}
private boolean equalTo(ImmutableComponent another) {
return kind.equals(another.kind)
&& scheme.equals(another.scheme)
&& syntax.equals(another.syntax)
&& title.equals(another.title)
&& description.equals(another.description)
&& label.equals(another.label)
&& deprecated.equals(another.deprecated)
&& consumerOnly.equals(another.consumerOnly)
&& producerOnly.equals(another.producerOnly)
&& javaType.equals(another.javaType)
&& groupId.equals(another.groupId)
&& artifactId.equals(another.artifactId)
&& version.equals(another.version)
&& Objects.equals(alternativeSyntax, another.alternativeSyntax)
&& Objects.equals(alternativeSchemes, another.alternativeSchemes)
&& Objects.equals(firstVersion, another.firstVersion);
}
/**
* Computes a hash code from attributes: {@code kind}, {@code scheme}, {@code syntax}, {@code title}, {@code description}, {@code label}, {@code deprecated}, {@code consumerOnly}, {@code producerOnly}, {@code javaType}, {@code groupId}, {@code artifactId}, {@code version}, {@code alternativeSyntax}, {@code alternativeSchemes}, {@code firstVersion}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + kind.hashCode();
h += (h << 5) + scheme.hashCode();
h += (h << 5) + syntax.hashCode();
h += (h << 5) + title.hashCode();
h += (h << 5) + description.hashCode();
h += (h << 5) + label.hashCode();
h += (h << 5) + deprecated.hashCode();
h += (h << 5) + consumerOnly.hashCode();
h += (h << 5) + producerOnly.hashCode();
h += (h << 5) + javaType.hashCode();
h += (h << 5) + groupId.hashCode();
h += (h << 5) + artifactId.hashCode();
h += (h << 5) + version.hashCode();
h += (h << 5) + Objects.hashCode(alternativeSyntax);
h += (h << 5) + Objects.hashCode(alternativeSchemes);
h += (h << 5) + Objects.hashCode(firstVersion);
return h;
}
/**
* Prints the immutable value {@code Component} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("Component{");
builder.append("kind=").append(kind);
builder.append(", ");
builder.append("scheme=").append(scheme);
builder.append(", ");
builder.append("syntax=").append(syntax);
builder.append(", ");
builder.append("title=").append(title);
builder.append(", ");
builder.append("description=").append(description);
builder.append(", ");
builder.append("label=").append(label);
builder.append(", ");
builder.append("deprecated=").append(deprecated);
builder.append(", ");
builder.append("consumerOnly=").append(consumerOnly);
builder.append(", ");
builder.append("producerOnly=").append(producerOnly);
builder.append(", ");
builder.append("javaType=").append(javaType);
builder.append(", ");
builder.append("groupId=").append(groupId);
builder.append(", ");
builder.append("artifactId=").append(artifactId);
builder.append(", ");
builder.append("version=").append(version);
if (alternativeSyntax != null) {
builder.append(", ");
builder.append("alternativeSyntax=").append(alternativeSyntax);
}
if (alternativeSchemes != null) {
builder.append(", ");
builder.append("alternativeSchemes=").append(alternativeSchemes);
}
if (firstVersion != null) {
builder.append(", ");
builder.append("firstVersion=").append(firstVersion);
}
return builder.append("}").toString();
}
/**
* Creates an immutable copy of a {@link ComponentDefinition.Component} 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 Component instance
*/
public static ImmutableComponent copyOf(ComponentDefinition.Component instance) {
if (instance instanceof ImmutableComponent) {
return (ImmutableComponent) instance;
}
return new ImmutableComponent.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableComponent ImmutableComponent}.
* 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.
*/
@Generated(from = "ComponentDefinition.Component", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_KIND = 0x1L;
private static final long INIT_BIT_SCHEME = 0x2L;
private static final long INIT_BIT_SYNTAX = 0x4L;
private static final long INIT_BIT_TITLE = 0x8L;
private static final long INIT_BIT_DESCRIPTION = 0x10L;
private static final long INIT_BIT_LABEL = 0x20L;
private static final long INIT_BIT_DEPRECATED = 0x40L;
private static final long INIT_BIT_CONSUMER_ONLY = 0x80L;
private static final long INIT_BIT_PRODUCER_ONLY = 0x100L;
private static final long INIT_BIT_JAVA_TYPE = 0x200L;
private static final long INIT_BIT_GROUP_ID = 0x400L;
private static final long INIT_BIT_ARTIFACT_ID = 0x800L;
private static final long INIT_BIT_VERSION = 0x1000L;
private long initBits = 0x1fffL;
private String kind;
private String scheme;
private String syntax;
private String title;
private String description;
private String label;
private String deprecated;
private String consumerOnly;
private String producerOnly;
private String javaType;
private String groupId;
private String artifactId;
private String version;
private String alternativeSyntax;
private String alternativeSchemes;
private String firstVersion;
/**
* Creates a builder for {@link ImmutableComponent ImmutableComponent} instances.
*
* new ImmutableComponent.Builder()
* .kind(String) // required {@link ComponentDefinition.Component#getKind() kind}
* .scheme(String) // required {@link ComponentDefinition.Component#getScheme() scheme}
* .syntax(String) // required {@link ComponentDefinition.Component#getSyntax() syntax}
* .title(String) // required {@link ComponentDefinition.Component#getTitle() title}
* .description(String) // required {@link ComponentDefinition.Component#getDescription() description}
* .label(String) // required {@link ComponentDefinition.Component#getLabel() label}
* .deprecated(String) // required {@link ComponentDefinition.Component#getDeprecated() deprecated}
* .consumerOnly(String) // required {@link ComponentDefinition.Component#getConsumerOnly() consumerOnly}
* .producerOnly(String) // required {@link ComponentDefinition.Component#getProducerOnly() producerOnly}
* .javaType(String) // required {@link ComponentDefinition.Component#getJavaType() javaType}
* .groupId(String) // required {@link ComponentDefinition.Component#getGroupId() groupId}
* .artifactId(String) // required {@link ComponentDefinition.Component#getArtifactId() artifactId}
* .version(String) // required {@link ComponentDefinition.Component#getVersion() version}
* .alternativeSyntax(String) // optional {@link ComponentDefinition.Component#getAlternativeSyntax() alternativeSyntax}
* .alternativeSchemes(String) // optional {@link ComponentDefinition.Component#getAlternativeSchemes() alternativeSchemes}
* .firstVersion(String) // optional {@link ComponentDefinition.Component#getFirstVersion() firstVersion}
* .build();
*
*/
public Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code Component} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(ComponentDefinition.Component instance) {
Objects.requireNonNull(instance, "instance");
kind(instance.getKind());
scheme(instance.getScheme());
syntax(instance.getSyntax());
title(instance.getTitle());
description(instance.getDescription());
label(instance.getLabel());
deprecated(instance.getDeprecated());
consumerOnly(instance.getConsumerOnly());
producerOnly(instance.getProducerOnly());
javaType(instance.getJavaType());
groupId(instance.getGroupId());
artifactId(instance.getArtifactId());
version(instance.getVersion());
Optional alternativeSyntaxOptional = instance.getAlternativeSyntax();
if (alternativeSyntaxOptional.isPresent()) {
alternativeSyntax(alternativeSyntaxOptional);
}
Optional alternativeSchemesOptional = instance.getAlternativeSchemes();
if (alternativeSchemesOptional.isPresent()) {
alternativeSchemes(alternativeSchemesOptional);
}
Optional firstVersionOptional = instance.getFirstVersion();
if (firstVersionOptional.isPresent()) {
firstVersion(firstVersionOptional);
}
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getKind() kind} attribute.
* @param kind The value for kind
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("kind")
public final Builder kind(String kind) {
this.kind = Objects.requireNonNull(kind, "kind");
initBits &= ~INIT_BIT_KIND;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getScheme() scheme} attribute.
* @param scheme The value for scheme
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("scheme")
public final Builder scheme(String scheme) {
this.scheme = Objects.requireNonNull(scheme, "scheme");
initBits &= ~INIT_BIT_SCHEME;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getSyntax() syntax} attribute.
* @param syntax The value for syntax
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("syntax")
public final Builder syntax(String syntax) {
this.syntax = Objects.requireNonNull(syntax, "syntax");
initBits &= ~INIT_BIT_SYNTAX;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getTitle() title} attribute.
* @param title The value for title
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("title")
public final Builder title(String title) {
this.title = Objects.requireNonNull(title, "title");
initBits &= ~INIT_BIT_TITLE;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getDescription() description} attribute.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("description")
public final Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
initBits &= ~INIT_BIT_DESCRIPTION;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getLabel() label} attribute.
* @param label The value for label
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("label")
public final Builder label(String label) {
this.label = Objects.requireNonNull(label, "label");
initBits &= ~INIT_BIT_LABEL;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getDeprecated() deprecated} attribute.
* @param deprecated The value for deprecated
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("deprecated")
public final Builder deprecated(String deprecated) {
this.deprecated = Objects.requireNonNull(deprecated, "deprecated");
initBits &= ~INIT_BIT_DEPRECATED;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getConsumerOnly() consumerOnly} attribute.
* @param consumerOnly The value for consumerOnly
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("consumerOnly")
public final Builder consumerOnly(String consumerOnly) {
this.consumerOnly = Objects.requireNonNull(consumerOnly, "consumerOnly");
initBits &= ~INIT_BIT_CONSUMER_ONLY;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getProducerOnly() producerOnly} attribute.
* @param producerOnly The value for producerOnly
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("producerOnly")
public final Builder producerOnly(String producerOnly) {
this.producerOnly = Objects.requireNonNull(producerOnly, "producerOnly");
initBits &= ~INIT_BIT_PRODUCER_ONLY;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getJavaType() javaType} attribute.
* @param javaType The value for javaType
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("javaType")
public final Builder javaType(String javaType) {
this.javaType = Objects.requireNonNull(javaType, "javaType");
initBits &= ~INIT_BIT_JAVA_TYPE;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getGroupId() groupId} attribute.
* @param groupId The value for groupId
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("groupId")
public final Builder groupId(String groupId) {
this.groupId = Objects.requireNonNull(groupId, "groupId");
initBits &= ~INIT_BIT_GROUP_ID;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getArtifactId() artifactId} attribute.
* @param artifactId The value for artifactId
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("artifactId")
public final Builder artifactId(String artifactId) {
this.artifactId = Objects.requireNonNull(artifactId, "artifactId");
initBits &= ~INIT_BIT_ARTIFACT_ID;
return this;
}
/**
* Initializes the value for the {@link ComponentDefinition.Component#getVersion() version} attribute.
* @param version The value for version
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("version")
public final Builder version(String version) {
this.version = Objects.requireNonNull(version, "version");
initBits &= ~INIT_BIT_VERSION;
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getAlternativeSyntax() alternativeSyntax} to alternativeSyntax.
* @param alternativeSyntax The value for alternativeSyntax
* @return {@code this} builder for chained invocation
*/
public final Builder alternativeSyntax(String alternativeSyntax) {
this.alternativeSyntax = Objects.requireNonNull(alternativeSyntax, "alternativeSyntax");
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getAlternativeSyntax() alternativeSyntax} to alternativeSyntax.
* @param alternativeSyntax The value for alternativeSyntax
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("alternativeSyntax")
public final Builder alternativeSyntax(Optional alternativeSyntax) {
this.alternativeSyntax = alternativeSyntax.orElse(null);
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getAlternativeSchemes() alternativeSchemes} to alternativeSchemes.
* @param alternativeSchemes The value for alternativeSchemes
* @return {@code this} builder for chained invocation
*/
public final Builder alternativeSchemes(String alternativeSchemes) {
this.alternativeSchemes = Objects.requireNonNull(alternativeSchemes, "alternativeSchemes");
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getAlternativeSchemes() alternativeSchemes} to alternativeSchemes.
* @param alternativeSchemes The value for alternativeSchemes
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("alternativeSchemes")
public final Builder alternativeSchemes(Optional alternativeSchemes) {
this.alternativeSchemes = alternativeSchemes.orElse(null);
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getFirstVersion() firstVersion} to firstVersion.
* @param firstVersion The value for firstVersion
* @return {@code this} builder for chained invocation
*/
public final Builder firstVersion(String firstVersion) {
this.firstVersion = Objects.requireNonNull(firstVersion, "firstVersion");
return this;
}
/**
* Initializes the optional value {@link ComponentDefinition.Component#getFirstVersion() firstVersion} to firstVersion.
* @param firstVersion The value for firstVersion
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("firstVersion")
public final Builder firstVersion(Optional firstVersion) {
this.firstVersion = firstVersion.orElse(null);
return this;
}
/**
* Builds a new {@link ImmutableComponent ImmutableComponent}.
* @return An immutable instance of Component
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableComponent build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ImmutableComponent(
kind,
scheme,
syntax,
title,
description,
label,
deprecated,
consumerOnly,
producerOnly,
javaType,
groupId,
artifactId,
version,
alternativeSyntax,
alternativeSchemes,
firstVersion);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_KIND) != 0) attributes.add("kind");
if ((initBits & INIT_BIT_SCHEME) != 0) attributes.add("scheme");
if ((initBits & INIT_BIT_SYNTAX) != 0) attributes.add("syntax");
if ((initBits & INIT_BIT_TITLE) != 0) attributes.add("title");
if ((initBits & INIT_BIT_DESCRIPTION) != 0) attributes.add("description");
if ((initBits & INIT_BIT_LABEL) != 0) attributes.add("label");
if ((initBits & INIT_BIT_DEPRECATED) != 0) attributes.add("deprecated");
if ((initBits & INIT_BIT_CONSUMER_ONLY) != 0) attributes.add("consumerOnly");
if ((initBits & INIT_BIT_PRODUCER_ONLY) != 0) attributes.add("producerOnly");
if ((initBits & INIT_BIT_JAVA_TYPE) != 0) attributes.add("javaType");
if ((initBits & INIT_BIT_GROUP_ID) != 0) attributes.add("groupId");
if ((initBits & INIT_BIT_ARTIFACT_ID) != 0) attributes.add("artifactId");
if ((initBits & INIT_BIT_VERSION) != 0) attributes.add("version");
return "Cannot build Component, some of required attributes are not set " + attributes;
}
}
}