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

io.syndesis.common.model.connection.ImmutableConfigurationProperty Maven / Gradle / Ivy

There is a newer version: 1.13.2
Show newest version
/*
 * Copyright (C) 2016 Red Hat, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.syndesis.common.model.connection;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.syndesis.common.model.Ordered;
import io.syndesis.common.model.WithTags;
import io.syndesis.common.util.json.StringTrimmingConverter;
import java.io.ObjectStreamException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.annotation.Generated;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.Validator;

/**
 * Immutable implementation of {@link ConfigurationProperty}.
 * 

* Use the builder to create immutable instances: * {@code new ConfigurationProperty.Builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableConfigurationProperty.of()}. */ @SuppressWarnings({"all"}) @SuppressFBWarnings @Generated({"Immutables.generator", "ConfigurationProperty"}) final class ImmutableConfigurationProperty implements ConfigurationProperty { private final Boolean componentProperty; private final String defaultValue; private final Boolean deprecated; private final String description; private final String controlHint; private final String labelHint; private final String placeholder; private final String displayName; private final List getEnum; private final String group; private final String javaType; private final String kind; private final String label; private final Boolean required; private final Boolean secret; private final String type; private final String connectorValue; private final Boolean raw; private final List relation; private final SortedSet tags; private final Integer order; private ImmutableConfigurationProperty( Boolean componentProperty, String defaultValue, Boolean deprecated, String description, String controlHint, String labelHint, String placeholder, String displayName, Iterable getEnum, String group, String javaType, String kind, String label, Boolean required, Boolean secret, String type, Optional connectorValue, Boolean raw, Iterable relation, Iterable tags, OptionalInt order) { this.componentProperty = componentProperty; this.defaultValue = defaultValue; this.deprecated = deprecated; this.description = description; this.controlHint = controlHint; this.labelHint = labelHint; this.placeholder = placeholder; this.displayName = displayName; this.getEnum = createUnmodifiableList(false, createSafeList(getEnum, true, false)); this.group = group; this.javaType = javaType; this.kind = kind; this.label = label; this.required = required; this.secret = secret; this.type = type; this.connectorValue = connectorValue.orElse(null); this.raw = raw; this.relation = createUnmodifiableList(false, createSafeList(relation, true, false)); this.tags = createUnmodifiableSortedSet(false, createSafeList(tags, false, true)); this.order = order.isPresent() ? order.getAsInt() : null; } private ImmutableConfigurationProperty( ImmutableConfigurationProperty original, Boolean componentProperty, String defaultValue, Boolean deprecated, String description, String controlHint, String labelHint, String placeholder, String displayName, List getEnum, String group, String javaType, String kind, String label, Boolean required, Boolean secret, String type, String connectorValue, Boolean raw, List relation, SortedSet tags, Integer order) { this.componentProperty = componentProperty; this.defaultValue = defaultValue; this.deprecated = deprecated; this.description = description; this.controlHint = controlHint; this.labelHint = labelHint; this.placeholder = placeholder; this.displayName = displayName; this.getEnum = getEnum; this.group = group; this.javaType = javaType; this.kind = kind; this.label = label; this.required = required; this.secret = secret; this.type = type; this.connectorValue = connectorValue; this.raw = raw; this.relation = relation; this.tags = tags; this.order = order; } /** * @return The value of the {@code componentProperty} attribute */ @JsonProperty("componentProperty") @Override public Boolean getComponentProperty() { return componentProperty; } /** * @return The value of the {@code defaultValue} attribute */ @JsonProperty("defaultValue") @Override public String getDefaultValue() { return defaultValue; } /** * @return The value of the {@code deprecated} attribute */ @JsonProperty("deprecated") @Override public Boolean getDeprecated() { return deprecated; } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @Override public String getDescription() { return description; } /** * @return The value of the {@code controlHint} attribute */ @JsonProperty("controlHint") @Override public String getControlHint() { return controlHint; } /** * @return The value of the {@code labelHint} attribute */ @JsonProperty("labelHint") @Override public String getLabelHint() { return labelHint; } /** * @return The value of the {@code placeholder} attribute */ @JsonProperty("placeholder") @Override public String getPlaceholder() { return placeholder; } /** * @return The value of the {@code displayName} attribute */ @JsonProperty("displayName") @Override public String getDisplayName() { return displayName; } /** * @return The value of the {@code getEnum} attribute */ @JsonProperty("enum") @Override public List getEnum() { return getEnum; } /** * @return The value of the {@code group} attribute */ @JsonProperty("group") @Override public String getGroup() { return group; } /** * @return The value of the {@code javaType} attribute */ @JsonProperty("javaType") @Override public String getJavaType() { return javaType; } /** * @return The value of the {@code kind} attribute */ @JsonProperty("kind") @Override public String getKind() { return kind; } /** * @return The value of the {@code label} attribute */ @JsonProperty("label") @Override public String getLabel() { return label; } /** * @return The value of the {@code required} attribute */ @JsonProperty("required") @Override public Boolean getRequired() { return required; } /** * @return The value of the {@code secret} attribute */ @JsonProperty("secret") @Override public Boolean getSecret() { return secret; } /** * @return The value of the {@code type} attribute */ @JsonProperty("type") @Override public String getType() { return type; } /** * @return The value of the {@code connectorValue} attribute */ @JsonProperty("connectorValue") @Override public Optional getConnectorValue() { return Optional.ofNullable(connectorValue); } /** * @return The value of the {@code raw} attribute */ @JsonProperty("raw") @Override public Boolean getRaw() { return raw; } /** * @return The value of the {@code relation} attribute */ @JsonProperty("relation") @Override public List getRelation() { return relation; } /** * @return The value of the {@code tags} attribute */ @JsonProperty("tags") @JsonDeserialize(contentConverter = StringTrimmingConverter.class) @Override public SortedSet getTags() { return tags; } /** * @return The value of the {@code order} attribute */ @JsonProperty("order") @Override public OptionalInt getOrder() { return order != null ? OptionalInt.of(order) : OptionalInt.empty(); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getComponentProperty() componentProperty} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for componentProperty (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withComponentProperty(Boolean value) { if (Objects.equals(this.componentProperty, value)) return this; return validate(new ImmutableConfigurationProperty( this, value, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getDefaultValue() defaultValue} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for defaultValue (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withDefaultValue(String value) { if (Objects.equals(this.defaultValue, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, value, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#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 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withDeprecated(Boolean value) { if (Objects.equals(this.deprecated, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, value, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#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 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withDescription(String value) { if (Objects.equals(this.description, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, value, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getControlHint() controlHint} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for controlHint (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withControlHint(String value) { if (Objects.equals(this.controlHint, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, value, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getLabelHint() labelHint} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for labelHint (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withLabelHint(String value) { if (Objects.equals(this.labelHint, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, value, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getPlaceholder() placeholder} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for placeholder (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withPlaceholder(String value) { if (Objects.equals(this.placeholder, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, value, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getDisplayName() displayName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for displayName (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withDisplayName(String value) { if (Objects.equals(this.displayName, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, value, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#getEnum() enum}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withEnum(ConfigurationProperty.PropertyValue... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, newValue, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#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 ImmutableConfigurationProperty withEnum(Iterable elements) { if (this.getEnum == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, newValue, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getGroup() group} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for group (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withGroup(String value) { if (Objects.equals(this.group, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, value, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#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 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withJavaType(String value) { if (Objects.equals(this.javaType, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, value, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#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 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withKind(String value) { if (Objects.equals(this.kind, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, value, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#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 (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withLabel(String value) { if (Objects.equals(this.label, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, value, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getRequired() required} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for required (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withRequired(Boolean value) { if (Objects.equals(this.required, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, value, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getSecret() secret} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for secret (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withSecret(Boolean value) { if (Objects.equals(this.secret, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, value, this.type, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getType() type} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for type (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withType(String value) { if (Objects.equals(this.type, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, value, this.connectorValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a present value for the optional {@link ConfigurationProperty#getConnectorValue() connectorValue} attribute. * @param value The value for connectorValue * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withConnectorValue(String value) { String newValue = Objects.requireNonNull(value, "connectorValue"); if (Objects.equals(this.connectorValue, newValue)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, newValue, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting an optional value for the {@link ConfigurationProperty#getConnectorValue() connectorValue} 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 connectorValue * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withConnectorValue(Optional optional) { String value = optional.orElse(null); if (Objects.equals(this.connectorValue, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, value, this.raw, this.relation, this.tags, this.order)); } /** * Copy the current immutable object by setting a value for the {@link ConfigurationProperty#getRaw() raw} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for raw (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConfigurationProperty withRaw(Boolean value) { if (Objects.equals(this.raw, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, value, this.relation, this.tags, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#getRelation() relation}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withRelation(PropertyRelation... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, newValue, this.tags, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#getRelation() relation}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of relation elements to set * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withRelation(Iterable elements) { if (this.relation == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, newValue, this.tags, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#getTags() tags}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withTags(String... elements) { SortedSet newValue = createUnmodifiableSortedSet(false, createSafeList(Arrays.asList(elements), false, true)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, newValue, this.order)); } /** * Copy the current immutable object with elements that replace the content of {@link ConfigurationProperty#getTags() tags}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of tags elements to set * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withTags(Iterable elements) { if (this.tags == elements) return this; SortedSet newValue = createUnmodifiableSortedSet(false, createSafeList(elements, false, true)); return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, newValue, this.order)); } /** * Copy the current immutable object by setting a present value for the optional {@link ConfigurationProperty#getOrder() order} attribute. * @param value The value for order * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withOrder(int value) { Integer newValue = value; if (Objects.equals(this.order, newValue)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, newValue)); } /** * Copy the current immutable object by setting an optional value for the {@link ConfigurationProperty#getOrder() order} 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 order * @return A modified copy of {@code this} object */ public final ImmutableConfigurationProperty withOrder(OptionalInt optional) { Integer value = optional.isPresent() ? optional.getAsInt() : null; if (Objects.equals(this.order, value)) return this; return validate(new ImmutableConfigurationProperty( this, this.componentProperty, this.defaultValue, this.deprecated, this.description, this.controlHint, this.labelHint, this.placeholder, this.displayName, this.getEnum, this.group, this.javaType, this.kind, this.label, this.required, this.secret, this.type, this.connectorValue, this.raw, this.relation, this.tags, value)); } /** * This instance is equal to all instances of {@code ImmutableConfigurationProperty} 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 ImmutableConfigurationProperty && equalTo((ImmutableConfigurationProperty) another); } private boolean equalTo(ImmutableConfigurationProperty another) { return Objects.equals(componentProperty, another.componentProperty) && Objects.equals(defaultValue, another.defaultValue) && Objects.equals(deprecated, another.deprecated) && Objects.equals(description, another.description) && Objects.equals(controlHint, another.controlHint) && Objects.equals(labelHint, another.labelHint) && Objects.equals(placeholder, another.placeholder) && Objects.equals(displayName, another.displayName) && getEnum.equals(another.getEnum) && Objects.equals(group, another.group) && Objects.equals(javaType, another.javaType) && Objects.equals(kind, another.kind) && Objects.equals(label, another.label) && Objects.equals(required, another.required) && Objects.equals(secret, another.secret) && Objects.equals(type, another.type) && Objects.equals(connectorValue, another.connectorValue) && Objects.equals(raw, another.raw) && relation.equals(another.relation) && tags.equals(another.tags) && Objects.equals(order, another.order); } /** * Computes a hash code from attributes: {@code componentProperty}, {@code defaultValue}, {@code deprecated}, {@code description}, {@code controlHint}, {@code labelHint}, {@code placeholder}, {@code displayName}, {@code getEnum}, {@code group}, {@code javaType}, {@code kind}, {@code label}, {@code required}, {@code secret}, {@code type}, {@code connectorValue}, {@code raw}, {@code relation}, {@code tags}, {@code order}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(componentProperty); h += (h << 5) + Objects.hashCode(defaultValue); h += (h << 5) + Objects.hashCode(deprecated); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + Objects.hashCode(controlHint); h += (h << 5) + Objects.hashCode(labelHint); h += (h << 5) + Objects.hashCode(placeholder); h += (h << 5) + Objects.hashCode(displayName); h += (h << 5) + getEnum.hashCode(); h += (h << 5) + Objects.hashCode(group); h += (h << 5) + Objects.hashCode(javaType); h += (h << 5) + Objects.hashCode(kind); h += (h << 5) + Objects.hashCode(label); h += (h << 5) + Objects.hashCode(required); h += (h << 5) + Objects.hashCode(secret); h += (h << 5) + Objects.hashCode(type); h += (h << 5) + Objects.hashCode(connectorValue); h += (h << 5) + Objects.hashCode(raw); h += (h << 5) + relation.hashCode(); h += (h << 5) + tags.hashCode(); h += (h << 5) + Objects.hashCode(order); return h; } /** * Prints the immutable value {@code ConfigurationProperty} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ConfigurationProperty{"); if (componentProperty != null) { builder.append("componentProperty=").append(componentProperty); } if (defaultValue != null) { if (builder.length() > 22) builder.append(", "); builder.append("defaultValue=").append(defaultValue); } if (deprecated != null) { if (builder.length() > 22) builder.append(", "); builder.append("deprecated=").append(deprecated); } if (description != null) { if (builder.length() > 22) builder.append(", "); builder.append("description=").append(description); } if (controlHint != null) { if (builder.length() > 22) builder.append(", "); builder.append("controlHint=").append(controlHint); } if (labelHint != null) { if (builder.length() > 22) builder.append(", "); builder.append("labelHint=").append(labelHint); } if (placeholder != null) { if (builder.length() > 22) builder.append(", "); builder.append("placeholder=").append(placeholder); } if (displayName != null) { if (builder.length() > 22) builder.append(", "); builder.append("displayName=").append(displayName); } if (builder.length() > 22) builder.append(", "); builder.append("enum=").append(getEnum); if (group != null) { builder.append(", "); builder.append("group=").append(group); } if (javaType != null) { builder.append(", "); builder.append("javaType=").append(javaType); } if (kind != null) { builder.append(", "); builder.append("kind=").append(kind); } if (label != null) { builder.append(", "); builder.append("label=").append(label); } if (required != null) { builder.append(", "); builder.append("required=").append(required); } if (secret != null) { builder.append(", "); builder.append("secret=").append(secret); } if (type != null) { builder.append(", "); builder.append("type=").append(type); } if (connectorValue != null) { builder.append(", "); builder.append("connectorValue=").append(connectorValue); } if (raw != null) { builder.append(", "); builder.append("raw=").append(raw); } builder.append(", "); builder.append("relation=").append(relation); builder.append(", "); builder.append("tags=").append(tags); if (order != null) { builder.append(", "); builder.append("order=").append(order); } return builder.append("}").toString(); } /** * Construct a new immutable {@code ConfigurationProperty} instance. * @param componentProperty The value for the {@code componentProperty} attribute * @param defaultValue The value for the {@code defaultValue} attribute * @param deprecated The value for the {@code deprecated} attribute * @param description The value for the {@code description} attribute * @param controlHint The value for the {@code controlHint} attribute * @param labelHint The value for the {@code labelHint} attribute * @param placeholder The value for the {@code placeholder} attribute * @param displayName The value for the {@code displayName} attribute * @param getEnum The value for the {@code getEnum} attribute * @param group The value for the {@code group} attribute * @param javaType The value for the {@code javaType} attribute * @param kind The value for the {@code kind} attribute * @param label The value for the {@code label} attribute * @param required The value for the {@code required} attribute * @param secret The value for the {@code secret} attribute * @param type The value for the {@code type} attribute * @param connectorValue The value for the {@code connectorValue} attribute * @param raw The value for the {@code raw} attribute * @param relation The value for the {@code relation} attribute * @param tags The value for the {@code tags} attribute * @param order The value for the {@code order} attribute * @return An immutable ConfigurationProperty instance */ public static ConfigurationProperty of(Boolean componentProperty, String defaultValue, Boolean deprecated, String description, String controlHint, String labelHint, String placeholder, String displayName, List getEnum, String group, String javaType, String kind, String label, Boolean required, Boolean secret, String type, Optional connectorValue, Boolean raw, List relation, SortedSet tags, OptionalInt order) { return of(componentProperty, defaultValue, deprecated, description, controlHint, labelHint, placeholder, displayName, (Iterable) getEnum, group, javaType, kind, label, required, secret, type, connectorValue, raw, (Iterable) relation, (Iterable) tags, order); } /** * Construct a new immutable {@code ConfigurationProperty} instance. * @param componentProperty The value for the {@code componentProperty} attribute * @param defaultValue The value for the {@code defaultValue} attribute * @param deprecated The value for the {@code deprecated} attribute * @param description The value for the {@code description} attribute * @param controlHint The value for the {@code controlHint} attribute * @param labelHint The value for the {@code labelHint} attribute * @param placeholder The value for the {@code placeholder} attribute * @param displayName The value for the {@code displayName} attribute * @param getEnum The value for the {@code getEnum} attribute * @param group The value for the {@code group} attribute * @param javaType The value for the {@code javaType} attribute * @param kind The value for the {@code kind} attribute * @param label The value for the {@code label} attribute * @param required The value for the {@code required} attribute * @param secret The value for the {@code secret} attribute * @param type The value for the {@code type} attribute * @param connectorValue The value for the {@code connectorValue} attribute * @param raw The value for the {@code raw} attribute * @param relation The value for the {@code relation} attribute * @param tags The value for the {@code tags} attribute * @param order The value for the {@code order} attribute * @return An immutable ConfigurationProperty instance */ public static ConfigurationProperty of(Boolean componentProperty, String defaultValue, Boolean deprecated, String description, String controlHint, String labelHint, String placeholder, String displayName, Iterable getEnum, String group, String javaType, String kind, String label, Boolean required, Boolean secret, String type, Optional connectorValue, Boolean raw, Iterable relation, Iterable tags, OptionalInt order) { return validate(new ImmutableConfigurationProperty(componentProperty, defaultValue, deprecated, description, controlHint, labelHint, placeholder, displayName, getEnum, group, javaType, kind, label, required, secret, type, connectorValue, raw, relation, tags, order)); } private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private static ImmutableConfigurationProperty validate(ImmutableConfigurationProperty instance) { Set> constraintViolations = validator.validate(instance); if (!constraintViolations.isEmpty()) { throw new ConstraintViolationException(constraintViolations); } return instance; } /** * Creates an immutable copy of a {@link ConfigurationProperty} 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 ConfigurationProperty instance */ public static ConfigurationProperty copyOf(ConfigurationProperty instance) { if (instance instanceof ImmutableConfigurationProperty) { return (ImmutableConfigurationProperty) instance; } return new ConfigurationProperty.Builder() .createFrom(instance) .build(); } private Object readResolve() throws ObjectStreamException { return validate(this); } /** * Builds instances of type {@link ConfigurationProperty ConfigurationProperty}. * 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. */ public static class Builder { private Boolean componentProperty; private String defaultValue; private Boolean deprecated; private String description; private String controlHint; private String labelHint; private String placeholder; private String displayName; private List getEnum = new ArrayList(); private String group; private String javaType; private String kind; private String label; private Boolean required; private Boolean secret; private String type; private String connectorValue; private Boolean raw; private List relation = new ArrayList(); private List tags = new ArrayList(); private Integer order; /** * Creates a builder for {@link ConfigurationProperty ConfigurationProperty} instances. */ public Builder() { if (!(this instanceof ConfigurationProperty.Builder)) { throw new UnsupportedOperationException("Use: new ConfigurationProperty.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.Ordered} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder createFrom(Ordered instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConfigurationProperty.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.connection.ConfigurationProperty} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder createFrom(ConfigurationProperty instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConfigurationProperty.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithTags} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder createFrom(WithTags instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConfigurationProperty.Builder) this; } private void from(Object object) { if (object instanceof Ordered) { Ordered instance = (Ordered) object; OptionalInt orderOptional = instance.getOrder(); if (orderOptional.isPresent()) { order(orderOptional); } } if (object instanceof ConfigurationProperty) { ConfigurationProperty instance = (ConfigurationProperty) object; String defaultValueValue = instance.getDefaultValue(); if (defaultValueValue != null) { defaultValue(defaultValueValue); } String displayNameValue = instance.getDisplayName(); if (displayNameValue != null) { displayName(displayNameValue); } String kindValue = instance.getKind(); if (kindValue != null) { kind(kindValue); } Boolean deprecatedValue = instance.getDeprecated(); if (deprecatedValue != null) { deprecated(deprecatedValue); } String descriptionValue = instance.getDescription(); if (descriptionValue != null) { description(descriptionValue); } addAllEnum(instance.getEnum()); Optional connectorValueOptional = instance.getConnectorValue(); if (connectorValueOptional.isPresent()) { connectorValue(connectorValueOptional); } Boolean rawValue = instance.getRaw(); if (rawValue != null) { raw(rawValue); } String labelValue = instance.getLabel(); if (labelValue != null) { label(labelValue); } Boolean secretValue = instance.getSecret(); if (secretValue != null) { secret(secretValue); } String typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } Boolean requiredValue = instance.getRequired(); if (requiredValue != null) { required(requiredValue); } Boolean componentPropertyValue = instance.getComponentProperty(); if (componentPropertyValue != null) { componentProperty(componentPropertyValue); } String javaTypeValue = instance.getJavaType(); if (javaTypeValue != null) { javaType(javaTypeValue); } addAllRelation(instance.getRelation()); String controlHintValue = instance.getControlHint(); if (controlHintValue != null) { controlHint(controlHintValue); } String labelHintValue = instance.getLabelHint(); if (labelHintValue != null) { labelHint(labelHintValue); } String placeholderValue = instance.getPlaceholder(); if (placeholderValue != null) { placeholder(placeholderValue); } String groupValue = instance.getGroup(); if (groupValue != null) { group(groupValue); } } if (object instanceof WithTags) { WithTags instance = (WithTags) object; addAllTags(instance.getTags()); } } /** * Initializes the value for the {@link ConfigurationProperty#getComponentProperty() componentProperty} attribute. * @param componentProperty The value for componentProperty (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("componentProperty") public final ConfigurationProperty.Builder componentProperty(Boolean componentProperty) { this.componentProperty = componentProperty; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getDefaultValue() defaultValue} attribute. * @param defaultValue The value for defaultValue (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("defaultValue") public final ConfigurationProperty.Builder defaultValue(String defaultValue) { this.defaultValue = defaultValue; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getDeprecated() deprecated} attribute. * @param deprecated The value for deprecated (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("deprecated") public final ConfigurationProperty.Builder deprecated(Boolean deprecated) { this.deprecated = deprecated; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getDescription() description} attribute. * @param description The value for description (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("description") public final ConfigurationProperty.Builder description(String description) { this.description = description; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getControlHint() controlHint} attribute. * @param controlHint The value for controlHint (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("controlHint") public final ConfigurationProperty.Builder controlHint(String controlHint) { this.controlHint = controlHint; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getLabelHint() labelHint} attribute. * @param labelHint The value for labelHint (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("labelHint") public final ConfigurationProperty.Builder labelHint(String labelHint) { this.labelHint = labelHint; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getPlaceholder() placeholder} attribute. * @param placeholder The value for placeholder (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("placeholder") public final ConfigurationProperty.Builder placeholder(String placeholder) { this.placeholder = placeholder; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getDisplayName() displayName} attribute. * @param displayName The value for displayName (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("displayName") public final ConfigurationProperty.Builder displayName(String displayName) { this.displayName = displayName; return (ConfigurationProperty.Builder) this; } /** * Adds one element to {@link ConfigurationProperty#getEnum() enum} list. * @param element A getEnum element * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addEnum(ConfigurationProperty.PropertyValue element) { this.getEnum.add(Objects.requireNonNull(element, "getEnum element")); return (ConfigurationProperty.Builder) this; } /** * Adds elements to {@link ConfigurationProperty#getEnum() enum} list. * @param elements An array of getEnum elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addEnum(ConfigurationProperty.PropertyValue... elements) { for (ConfigurationProperty.PropertyValue element : elements) { this.getEnum.add(Objects.requireNonNull(element, "getEnum element")); } return (ConfigurationProperty.Builder) this; } /** * Sets or replaces all elements for {@link ConfigurationProperty#getEnum() enum} list. * @param elements An iterable of getEnum elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("enum") public final ConfigurationProperty.Builder getEnum(Iterable elements) { this.getEnum.clear(); return addAllEnum(elements); } /** * Adds elements to {@link ConfigurationProperty#getEnum() enum} list. * @param elements An iterable of getEnum elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addAllEnum(Iterable elements) { for (ConfigurationProperty.PropertyValue element : elements) { this.getEnum.add(Objects.requireNonNull(element, "getEnum element")); } return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getGroup() group} attribute. * @param group The value for group (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("group") public final ConfigurationProperty.Builder group(String group) { this.group = group; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getJavaType() javaType} attribute. * @param javaType The value for javaType (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("javaType") public final ConfigurationProperty.Builder javaType(String javaType) { this.javaType = javaType; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getKind() kind} attribute. * @param kind The value for kind (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("kind") public final ConfigurationProperty.Builder kind(String kind) { this.kind = kind; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getLabel() label} attribute. * @param label The value for label (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("label") public final ConfigurationProperty.Builder label(String label) { this.label = label; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getRequired() required} attribute. * @param required The value for required (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("required") public final ConfigurationProperty.Builder required(Boolean required) { this.required = required; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getSecret() secret} attribute. * @param secret The value for secret (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("secret") public final ConfigurationProperty.Builder secret(Boolean secret) { this.secret = secret; return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getType() type} attribute. * @param type The value for type (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("type") public final ConfigurationProperty.Builder type(String type) { this.type = type; return (ConfigurationProperty.Builder) this; } /** * Initializes the optional value {@link ConfigurationProperty#getConnectorValue() connectorValue} to connectorValue. * @param connectorValue The value for connectorValue * @return {@code this} builder for chained invocation */ public final ConfigurationProperty.Builder connectorValue(String connectorValue) { this.connectorValue = Objects.requireNonNull(connectorValue, "connectorValue"); return (ConfigurationProperty.Builder) this; } /** * Initializes the optional value {@link ConfigurationProperty#getConnectorValue() connectorValue} to connectorValue. * @param connectorValue The value for connectorValue * @return {@code this} builder for use in a chained invocation */ @JsonProperty("connectorValue") public final ConfigurationProperty.Builder connectorValue(Optional connectorValue) { this.connectorValue = connectorValue.orElse(null); return (ConfigurationProperty.Builder) this; } /** * Initializes the value for the {@link ConfigurationProperty#getRaw() raw} attribute. * @param raw The value for raw (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("raw") public final ConfigurationProperty.Builder raw(Boolean raw) { this.raw = raw; return (ConfigurationProperty.Builder) this; } /** * Adds one element to {@link ConfigurationProperty#getRelation() relation} list. * @param element A relation element * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addRelation(PropertyRelation element) { this.relation.add(Objects.requireNonNull(element, "relation element")); return (ConfigurationProperty.Builder) this; } /** * Adds elements to {@link ConfigurationProperty#getRelation() relation} list. * @param elements An array of relation elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addRelation(PropertyRelation... elements) { for (PropertyRelation element : elements) { this.relation.add(Objects.requireNonNull(element, "relation element")); } return (ConfigurationProperty.Builder) this; } /** * Sets or replaces all elements for {@link ConfigurationProperty#getRelation() relation} list. * @param elements An iterable of relation elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("relation") public final ConfigurationProperty.Builder relation(Iterable elements) { this.relation.clear(); return addAllRelation(elements); } /** * Adds elements to {@link ConfigurationProperty#getRelation() relation} list. * @param elements An iterable of relation elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addAllRelation(Iterable elements) { for (PropertyRelation element : elements) { this.relation.add(Objects.requireNonNull(element, "relation element")); } return (ConfigurationProperty.Builder) this; } /** * Adds one element to {@link ConfigurationProperty#getTags() tags} sortedSet. * @param element A tags element * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addTag(String element) { if (element != null) this.tags.add(element); return (ConfigurationProperty.Builder) this; } /** * Adds elements to {@link ConfigurationProperty#getTags() tags} sortedSet. * @param elements An array of tags elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addTag(String... elements) { for (String element : elements) { if (element != null) this.tags.add(element); } return (ConfigurationProperty.Builder) this; } /** * Sets or replaces all elements for {@link ConfigurationProperty#getTags() tags} sortedSet. * @param elements An iterable of tags elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("tags") @JsonDeserialize(contentConverter = StringTrimmingConverter.class) public final ConfigurationProperty.Builder tags(Iterable elements) { this.tags.clear(); return addAllTags(elements); } /** * Adds elements to {@link ConfigurationProperty#getTags() tags} sortedSet. * @param elements An iterable of tags elements * @return {@code this} builder for use in a chained invocation */ public final ConfigurationProperty.Builder addAllTags(Iterable elements) { for (String element : elements) { if (element != null) this.tags.add(element); } return (ConfigurationProperty.Builder) this; } /** * Initializes the optional value {@link ConfigurationProperty#getOrder() order} to order. * @param order The value for order * @return {@code this} builder for chained invocation */ public final ConfigurationProperty.Builder order(int order) { this.order = order; return (ConfigurationProperty.Builder) this; } /** * Initializes the optional value {@link ConfigurationProperty#getOrder() order} to order. * @param order The value for order * @return {@code this} builder for use in a chained invocation */ @JsonProperty("order") public final ConfigurationProperty.Builder order(OptionalInt order) { this.order = order.isPresent() ? order.getAsInt() : null; return (ConfigurationProperty.Builder) this; } /** * Builds a new {@link ConfigurationProperty ConfigurationProperty}. * @return An immutable instance of ConfigurationProperty * @throws java.lang.IllegalStateException if any required attributes are missing */ public ConfigurationProperty build() { return ImmutableConfigurationProperty.validate(new ImmutableConfigurationProperty( null, componentProperty, defaultValue, deprecated, description, controlHint, labelHint, placeholder, displayName, createUnmodifiableList(true, getEnum), group, javaType, kind, label, required, secret, type, connectorValue, raw, createUnmodifiableList(true, relation), createUnmodifiableSortedSet(false, createSafeList(tags, false, false)), order)); } } private static List createSafeList(Iterable iterable, boolean checkNulls, boolean skipNulls) { ArrayList list; if (iterable instanceof Collection) { int size = ((Collection) iterable).size(); if (size == 0) return Collections.emptyList(); list = new ArrayList(); } else { list = new ArrayList(); } for (T element : iterable) { if (skipNulls && element == null) continue; if (checkNulls) Objects.requireNonNull(element, "element"); list.add(element); } return list; } private static List createUnmodifiableList(boolean clone, List list) { switch(list.size()) { case 0: return Collections.emptyList(); case 1: return Collections.singletonList(list.get(0)); default: if (clone) { return Collections.unmodifiableList(new ArrayList(list)); } else { if (list instanceof ArrayList) { ((ArrayList) list).trimToSize(); } return Collections.unmodifiableList(list); } } } private static > NavigableSet createUnmodifiableSortedSet(boolean reverse, List list) { TreeSet set = reverse ? new TreeSet(Collections.reverseOrder()) : new TreeSet(); set.addAll(list); return Collections.unmodifiableNavigableSet(set); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy