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

io.syndesis.common.model.integration.ImmutableIntegration 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.integration;

import com.fasterxml.jackson.annotation.JsonInclude;
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.ResourceIdentifier;
import io.syndesis.common.model.WithConfigurationProperties;
import io.syndesis.common.model.WithConfiguredProperties;
import io.syndesis.common.model.WithModificationTimestamps;
import io.syndesis.common.model.WithName;
import io.syndesis.common.model.WithResourceId;
import io.syndesis.common.model.WithResources;
import io.syndesis.common.model.WithTags;
import io.syndesis.common.model.WithVersion;
import io.syndesis.common.model.connection.ConfigurationProperty;
import io.syndesis.common.model.connection.Connection;
import io.syndesis.common.util.json.OptionalStringTrimmingConverter;
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.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import javax.validation.ConstraintViolation;
import javax.validation.ConstraintViolationException;
import javax.validation.Validation;
import javax.validation.Validator;

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

* Use the builder to create immutable instances: * {@code new Integration.Builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableIntegration.of()}. */ @SuppressWarnings({"all", "deprecation"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "Integration"}) @Immutable final class ImmutableIntegration implements Integration { private final @Nullable String id; private final boolean isDeleted; private final List steps; private final List flows; private final List connections; private final @Nullable String description; private final Map properties; private final Map configuredProperties; private final int version; private final long createdAt; private final long updatedAt; private final SortedSet tags; private final String name; private final List resources; private ImmutableIntegration( Optional id, boolean isDeleted, Iterable steps, Iterable flows, Iterable connections, Optional description, Map properties, Map configuredProperties, int version, long createdAt, long updatedAt, Iterable tags, String name, Iterable resources) { this.id = id.orElse(null); this.isDeleted = isDeleted; this.steps = createUnmodifiableList(false, createSafeList(steps, true, false)); this.flows = createUnmodifiableList(false, createSafeList(flows, true, false)); this.connections = createUnmodifiableList(false, createSafeList(connections, true, false)); this.description = description.orElse(null); this.properties = createUnmodifiableMap(true, false, properties); this.configuredProperties = createUnmodifiableMap(true, false, configuredProperties); this.version = version; this.createdAt = createdAt; this.updatedAt = updatedAt; this.tags = createUnmodifiableSortedSet(false, createSafeList(tags, false, true)); this.name = name; this.resources = createUnmodifiableList(false, createSafeList(resources, true, false)); initShim.isDeleted(this.isDeleted); initShim.steps(this.steps); initShim.flows(this.flows); initShim.connections(this.connections); initShim.configuredProperties(this.configuredProperties); initShim.version(this.version); initShim.createdAt(this.createdAt); initShim.updatedAt(this.updatedAt); initShim.resources(this.resources); this.initShim = null; } private ImmutableIntegration(ImmutableIntegration.Builder builder) { this.id = builder.id; this.description = builder.description; this.properties = createUnmodifiableMap(false, false, builder.properties); this.tags = createUnmodifiableSortedSet(false, createSafeList(builder.tags, false, false)); this.name = builder.name; if (builder.isDeletedIsSet()) { initShim.isDeleted(builder.isDeleted); } if (builder.stepsIsSet()) { initShim.steps(createUnmodifiableList(true, builder.steps)); } if (builder.flowsIsSet()) { initShim.flows(createUnmodifiableList(true, builder.flows)); } if (builder.connectionsIsSet()) { initShim.connections(createUnmodifiableList(true, builder.connections)); } if (builder.configuredPropertiesIsSet()) { initShim.configuredProperties(createUnmodifiableMap(false, false, builder.configuredProperties)); } if (builder.versionIsSet()) { initShim.version(builder.version); } if (builder.createdAtIsSet()) { initShim.createdAt(builder.createdAt); } if (builder.updatedAtIsSet()) { initShim.updatedAt(builder.updatedAt); } if (builder.resourcesIsSet()) { initShim.resources(createUnmodifiableList(true, builder.resources)); } this.isDeleted = initShim.isDeleted(); this.steps = initShim.getSteps(); this.flows = initShim.getFlows(); this.connections = initShim.getConnections(); this.configuredProperties = initShim.getConfiguredProperties(); this.version = initShim.getVersion(); this.createdAt = initShim.getCreatedAt(); this.updatedAt = initShim.getUpdatedAt(); this.resources = initShim.getResources(); this.initShim = null; } private ImmutableIntegration( ImmutableIntegration original, @Nullable String id, boolean isDeleted, List steps, List flows, List connections, @Nullable String description, Map properties, Map configuredProperties, int version, long createdAt, long updatedAt, SortedSet tags, String name, List resources) { this.id = id; this.isDeleted = isDeleted; this.steps = steps; this.flows = flows; this.connections = connections; this.description = description; this.properties = properties; this.configuredProperties = configuredProperties; this.version = version; this.createdAt = createdAt; this.updatedAt = updatedAt; this.tags = tags; this.name = name; this.resources = resources; this.initShim = null; } private static final int STAGE_INITIALIZING = -1; private static final int STAGE_UNINITIALIZED = 0; private static final int STAGE_INITIALIZED = 1; private transient volatile InitShim initShim = new InitShim(); private final class InitShim { private boolean isDeleted; private int isDeletedBuildStage; boolean isDeleted() { if (isDeletedBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (isDeletedBuildStage == STAGE_UNINITIALIZED) { isDeletedBuildStage = STAGE_INITIALIZING; this.isDeleted = isDeletedInitialize(); isDeletedBuildStage = STAGE_INITIALIZED; } return this.isDeleted; } void isDeleted(boolean isDeleted) { this.isDeleted = isDeleted; isDeletedBuildStage = STAGE_INITIALIZED; } private List steps; private int stepsBuildStage; List getSteps() { if (stepsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (stepsBuildStage == STAGE_UNINITIALIZED) { stepsBuildStage = STAGE_INITIALIZING; this.steps = createUnmodifiableList(false, createSafeList(getStepsInitialize(), true, false)); stepsBuildStage = STAGE_INITIALIZED; } return this.steps; } void steps(List steps) { this.steps = steps; stepsBuildStage = STAGE_INITIALIZED; } private List flows; private int flowsBuildStage; List getFlows() { if (flowsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (flowsBuildStage == STAGE_UNINITIALIZED) { flowsBuildStage = STAGE_INITIALIZING; this.flows = createUnmodifiableList(false, createSafeList(getFlowsInitialize(), true, false)); flowsBuildStage = STAGE_INITIALIZED; } return this.flows; } void flows(List flows) { this.flows = flows; flowsBuildStage = STAGE_INITIALIZED; } private List connections; private int connectionsBuildStage; List getConnections() { if (connectionsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (connectionsBuildStage == STAGE_UNINITIALIZED) { connectionsBuildStage = STAGE_INITIALIZING; this.connections = createUnmodifiableList(false, createSafeList(getConnectionsInitialize(), true, false)); connectionsBuildStage = STAGE_INITIALIZED; } return this.connections; } void connections(List connections) { this.connections = connections; connectionsBuildStage = STAGE_INITIALIZED; } private Map configuredProperties; private int configuredPropertiesBuildStage; Map getConfiguredProperties() { if (configuredPropertiesBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (configuredPropertiesBuildStage == STAGE_UNINITIALIZED) { configuredPropertiesBuildStage = STAGE_INITIALIZING; this.configuredProperties = createUnmodifiableMap(true, false, getConfiguredPropertiesInitialize()); configuredPropertiesBuildStage = STAGE_INITIALIZED; } return this.configuredProperties; } void configuredProperties(Map configuredProperties) { this.configuredProperties = configuredProperties; configuredPropertiesBuildStage = STAGE_INITIALIZED; } private int version; private int versionBuildStage; int getVersion() { if (versionBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (versionBuildStage == STAGE_UNINITIALIZED) { versionBuildStage = STAGE_INITIALIZING; this.version = getVersionInitialize(); versionBuildStage = STAGE_INITIALIZED; } return this.version; } void version(int version) { this.version = version; versionBuildStage = STAGE_INITIALIZED; } private long createdAt; private int createdAtBuildStage; long getCreatedAt() { if (createdAtBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (createdAtBuildStage == STAGE_UNINITIALIZED) { createdAtBuildStage = STAGE_INITIALIZING; this.createdAt = getCreatedAtInitialize(); createdAtBuildStage = STAGE_INITIALIZED; } return this.createdAt; } void createdAt(long createdAt) { this.createdAt = createdAt; createdAtBuildStage = STAGE_INITIALIZED; } private long updatedAt; private int updatedAtBuildStage; long getUpdatedAt() { if (updatedAtBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (updatedAtBuildStage == STAGE_UNINITIALIZED) { updatedAtBuildStage = STAGE_INITIALIZING; this.updatedAt = getUpdatedAtInitialize(); updatedAtBuildStage = STAGE_INITIALIZED; } return this.updatedAt; } void updatedAt(long updatedAt) { this.updatedAt = updatedAt; updatedAtBuildStage = STAGE_INITIALIZED; } private List resources; private int resourcesBuildStage; List getResources() { if (resourcesBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (resourcesBuildStage == STAGE_UNINITIALIZED) { resourcesBuildStage = STAGE_INITIALIZING; this.resources = createUnmodifiableList(false, createSafeList(getResourcesInitialize(), true, false)); resourcesBuildStage = STAGE_INITIALIZED; } return this.resources; } void resources(List resources) { this.resources = resources; resourcesBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { ArrayList attributes = new ArrayList(); if (isDeletedBuildStage == STAGE_INITIALIZING) attributes.add("isDeleted"); if (stepsBuildStage == STAGE_INITIALIZING) attributes.add("steps"); if (flowsBuildStage == STAGE_INITIALIZING) attributes.add("flows"); if (connectionsBuildStage == STAGE_INITIALIZING) attributes.add("connections"); if (configuredPropertiesBuildStage == STAGE_INITIALIZING) attributes.add("configuredProperties"); if (versionBuildStage == STAGE_INITIALIZING) attributes.add("version"); if (createdAtBuildStage == STAGE_INITIALIZING) attributes.add("createdAt"); if (updatedAtBuildStage == STAGE_INITIALIZING) attributes.add("updatedAt"); if (resourcesBuildStage == STAGE_INITIALIZING) attributes.add("resources"); return "Cannot build Integration, attribute initializers form cycle" + attributes; } } private boolean isDeletedInitialize() { return Integration.super.isDeleted(); } private List getStepsInitialize() { return Integration.super.getSteps(); } private List getFlowsInitialize() { return Integration.super.getFlows(); } private List getConnectionsInitialize() { return Integration.super.getConnections(); } private Map getConfiguredPropertiesInitialize() { return Integration.super.getConfiguredProperties(); } private int getVersionInitialize() { return Integration.super.getVersion(); } private long getCreatedAtInitialize() { return Integration.super.getCreatedAt(); } private long getUpdatedAtInitialize() { return Integration.super.getUpdatedAt(); } private List getResourcesInitialize() { return Integration.super.getResources(); } /** * @return The value of the {@code id} attribute */ @JsonProperty("id") @Override public Optional getId() { return Optional.ofNullable(id); } /** * @return The value of the {@code isDeleted} attribute */ @JsonProperty("isDeleted") @JsonInclude(JsonInclude.Include.NON_DEFAULT) @Override public boolean isDeleted() { InitShim shim = this.initShim; return shim != null ? shim.isDeleted() : this.isDeleted; } /** * @return The value of the {@code steps} attribute */ @JsonProperty("steps") @Deprecated @Override public List getSteps() { InitShim shim = this.initShim; return shim != null ? shim.getSteps() : this.steps; } /** * @return The value of the {@code flows} attribute */ @JsonProperty("flows") @Override public List getFlows() { InitShim shim = this.initShim; return shim != null ? shim.getFlows() : this.flows; } /** * @return The value of the {@code connections} attribute */ @JsonProperty("connections") @Override public List getConnections() { InitShim shim = this.initShim; return shim != null ? shim.getConnections() : this.connections; } /** * @return The value of the {@code description} attribute */ @JsonProperty("description") @JsonDeserialize(converter = OptionalStringTrimmingConverter.class) @Override public Optional getDescription() { return Optional.ofNullable(description); } /** * @return The value of the {@code properties} attribute */ @JsonProperty("properties") @Override public Map getProperties() { return properties; } /** * @return The value of the {@code configuredProperties} attribute */ @JsonProperty("configuredProperties") @Override public Map getConfiguredProperties() { InitShim shim = this.initShim; return shim != null ? shim.getConfiguredProperties() : this.configuredProperties; } /** * @return The value of the {@code version} attribute */ @JsonProperty("version") @Override public int getVersion() { InitShim shim = this.initShim; return shim != null ? shim.getVersion() : this.version; } /** * @return The value of the {@code createdAt} attribute */ @JsonProperty("createdAt") @Override public long getCreatedAt() { InitShim shim = this.initShim; return shim != null ? shim.getCreatedAt() : this.createdAt; } /** * @return The value of the {@code updatedAt} attribute */ @JsonProperty("updatedAt") @Override public long getUpdatedAt() { InitShim shim = this.initShim; return shim != null ? shim.getUpdatedAt() : this.updatedAt; } /** * @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 name} attribute */ @JsonProperty("name") @JsonDeserialize(converter = StringTrimmingConverter.class) @Override public String getName() { return name; } /** * @return The value of the {@code resources} attribute */ @JsonProperty("resources") @Override public List getResources() { InitShim shim = this.initShim; return shim != null ? shim.getResources() : this.resources; } /** * Copy the current immutable object by setting a present value for the optional {@link Integration#getId() id} attribute. * @param value The value for id * @return A modified copy of {@code this} object */ public final ImmutableIntegration withId(String value) { @Nullable String newValue = Objects.requireNonNull(value, "id"); if (Objects.equals(this.id, newValue)) return this; return validate(new ImmutableIntegration( this, newValue, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting an optional value for the {@link Integration#getId() id} 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 id * @return A modified copy of {@code this} object */ public final ImmutableIntegration withId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.id, value)) return this; return validate(new ImmutableIntegration( this, value, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting a value for the {@link Integration#isDeleted() isDeleted} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for isDeleted * @return A modified copy of the {@code this} object */ public final ImmutableIntegration withIsDeleted(boolean value) { if (this.isDeleted == value) return this; return validate(new ImmutableIntegration( this, this.id, value, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getSteps() steps}. * @param elements The elements to set * @return A modified copy of {@code this} object */ @Deprecated public final ImmutableIntegration withSteps(Step... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, newValue, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getSteps() steps}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of steps elements to set * @return A modified copy of {@code this} object */ @Deprecated public final ImmutableIntegration withSteps(Iterable elements) { if (this.steps == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, newValue, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getFlows() flows}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withFlows(Flow... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, newValue, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getFlows() flows}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of flows elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withFlows(Iterable elements) { if (this.flows == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, newValue, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getConnections() connections}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withConnections(Connection... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, newValue, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getConnections() connections}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of connections elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withConnections(Iterable elements) { if (this.connections == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, newValue, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting a present value for the optional {@link Integration#getDescription() description} attribute. * @param value The value for description * @return A modified copy of {@code this} object */ public final ImmutableIntegration withDescription(String value) { @Nullable String newValue = Objects.requireNonNull(value, "description"); if (Objects.equals(this.description, newValue)) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, newValue, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting an optional value for the {@link Integration#getDescription() description} attribute. * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}. * @param optional A value for description * @return A modified copy of {@code this} object */ public final ImmutableIntegration withDescription(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, value, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by replacing the {@link Integration#getProperties() properties} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the properties map * @return A modified copy of {@code this} object */ public final ImmutableIntegration withProperties(Map entries) { if (this.properties == entries) return this; Map newValue = createUnmodifiableMap(true, false, entries); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, newValue, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by replacing the {@link Integration#getConfiguredProperties() configuredProperties} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the configuredProperties map * @return A modified copy of {@code this} object */ public final ImmutableIntegration withConfiguredProperties(Map entries) { if (this.configuredProperties == entries) return this; Map newValue = createUnmodifiableMap(true, false, entries); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, newValue, this.version, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting a value for the {@link Integration#getVersion() version} attribute. * A value equality check is 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 ImmutableIntegration withVersion(int value) { if (this.version == value) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, value, this.createdAt, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting a value for the {@link Integration#getCreatedAt() createdAt} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for createdAt * @return A modified copy of the {@code this} object */ public final ImmutableIntegration withCreatedAt(long value) { if (this.createdAt == value) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, value, this.updatedAt, this.tags, this.name, this.resources)); } /** * Copy the current immutable object by setting a value for the {@link Integration#getUpdatedAt() updatedAt} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for updatedAt * @return A modified copy of the {@code this} object */ public final ImmutableIntegration withUpdatedAt(long value) { if (this.updatedAt == value) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, value, this.tags, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getTags() tags}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withTags(String... elements) { SortedSet newValue = createUnmodifiableSortedSet(false, createSafeList(Arrays.asList(elements), false, true)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, newValue, this.name, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#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 ImmutableIntegration withTags(Iterable elements) { if (this.tags == elements) return this; SortedSet newValue = createUnmodifiableSortedSet(false, createSafeList(elements, false, true)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, newValue, this.name, this.resources)); } /** * Copy the current immutable object by setting a value for the {@link Integration#getName() name} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for name (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableIntegration withName(String value) { if (Objects.equals(this.name, value)) return this; return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, value, this.resources)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getResources() resources}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withResources(ResourceIdentifier... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, newValue)); } /** * Copy the current immutable object with elements that replace the content of {@link Integration#getResources() resources}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of resources elements to set * @return A modified copy of {@code this} object */ public final ImmutableIntegration withResources(Iterable elements) { if (this.resources == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableIntegration( this, this.id, this.isDeleted, this.steps, this.flows, this.connections, this.description, this.properties, this.configuredProperties, this.version, this.createdAt, this.updatedAt, this.tags, this.name, newValue)); } /** * This instance is equal to all instances of {@code ImmutableIntegration} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableIntegration && equalTo((ImmutableIntegration) another); } private boolean equalTo(ImmutableIntegration another) { return Objects.equals(id, another.id) && isDeleted == another.isDeleted && steps.equals(another.steps) && flows.equals(another.flows) && connections.equals(another.connections) && Objects.equals(description, another.description) && properties.equals(another.properties) && configuredProperties.equals(another.configuredProperties) && version == another.version && createdAt == another.createdAt && updatedAt == another.updatedAt && tags.equals(another.tags) && Objects.equals(name, another.name) && resources.equals(another.resources); } /** * Computes a hash code from attributes: {@code id}, {@code isDeleted}, {@code steps}, {@code flows}, {@code connections}, {@code description}, {@code properties}, {@code configuredProperties}, {@code version}, {@code createdAt}, {@code updatedAt}, {@code tags}, {@code name}, {@code resources}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(id); h += (h << 5) + Boolean.hashCode(isDeleted); h += (h << 5) + steps.hashCode(); h += (h << 5) + flows.hashCode(); h += (h << 5) + connections.hashCode(); h += (h << 5) + Objects.hashCode(description); h += (h << 5) + properties.hashCode(); h += (h << 5) + configuredProperties.hashCode(); h += (h << 5) + version; h += (h << 5) + Long.hashCode(createdAt); h += (h << 5) + Long.hashCode(updatedAt); h += (h << 5) + tags.hashCode(); h += (h << 5) + Objects.hashCode(name); h += (h << 5) + resources.hashCode(); return h; } /** * Prints the immutable value {@code Integration} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("Integration{"); if (id != null) { builder.append("id=").append(id); } if (builder.length() > 12) builder.append(", "); builder.append("isDeleted=").append(isDeleted); builder.append(", "); builder.append("steps=").append(steps); builder.append(", "); builder.append("flows=").append(flows); builder.append(", "); builder.append("connections=").append(connections); if (description != null) { builder.append(", "); builder.append("description=").append(description); } builder.append(", "); builder.append("properties=").append(properties); builder.append(", "); builder.append("configuredProperties=").append(configuredProperties); builder.append(", "); builder.append("version=").append(version); builder.append(", "); builder.append("createdAt=").append(createdAt); builder.append(", "); builder.append("updatedAt=").append(updatedAt); builder.append(", "); builder.append("tags=").append(tags); if (name != null) { builder.append(", "); builder.append("name=").append(name); } builder.append(", "); builder.append("resources=").append(resources); return builder.append("}").toString(); } /** * Construct a new immutable {@code Integration} instance. * @param id The value for the {@code id} attribute * @param isDeleted The value for the {@code isDeleted} attribute * @param steps The value for the {@code steps} attribute * @param flows The value for the {@code flows} attribute * @param connections The value for the {@code connections} attribute * @param description The value for the {@code description} attribute * @param properties The value for the {@code properties} attribute * @param configuredProperties The value for the {@code configuredProperties} attribute * @param version The value for the {@code version} attribute * @param createdAt The value for the {@code createdAt} attribute * @param updatedAt The value for the {@code updatedAt} attribute * @param tags The value for the {@code tags} attribute * @param name The value for the {@code name} attribute * @param resources The value for the {@code resources} attribute * @return An immutable Integration instance */ public static Integration of(Optional id, boolean isDeleted, List steps, List flows, List connections, Optional description, Map properties, Map configuredProperties, int version, long createdAt, long updatedAt, SortedSet tags, String name, List resources) { return of(id, isDeleted, (Iterable) steps, (Iterable) flows, (Iterable) connections, description, properties, configuredProperties, version, createdAt, updatedAt, (Iterable) tags, name, (Iterable) resources); } /** * Construct a new immutable {@code Integration} instance. * @param id The value for the {@code id} attribute * @param isDeleted The value for the {@code isDeleted} attribute * @param steps The value for the {@code steps} attribute * @param flows The value for the {@code flows} attribute * @param connections The value for the {@code connections} attribute * @param description The value for the {@code description} attribute * @param properties The value for the {@code properties} attribute * @param configuredProperties The value for the {@code configuredProperties} attribute * @param version The value for the {@code version} attribute * @param createdAt The value for the {@code createdAt} attribute * @param updatedAt The value for the {@code updatedAt} attribute * @param tags The value for the {@code tags} attribute * @param name The value for the {@code name} attribute * @param resources The value for the {@code resources} attribute * @return An immutable Integration instance */ public static Integration of(Optional id, boolean isDeleted, Iterable steps, Iterable flows, Iterable connections, Optional description, Map properties, Map configuredProperties, int version, long createdAt, long updatedAt, Iterable tags, String name, Iterable resources) { return validate(new ImmutableIntegration(id, isDeleted, steps, flows, connections, description, properties, configuredProperties, version, createdAt, updatedAt, tags, name, resources)); } private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private static ImmutableIntegration validate(ImmutableIntegration instance) { Set> constraintViolations = validator.validate(instance); if (!constraintViolations.isEmpty()) { throw new ConstraintViolationException(constraintViolations); } return instance; } /** * Creates an immutable copy of a {@link Integration} 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 Integration instance */ public static Integration copyOf(Integration instance) { if (instance instanceof ImmutableIntegration) { return (ImmutableIntegration) instance; } return new Integration.Builder() .createFrom(instance) .build(); } private Object readResolve() throws ObjectStreamException { return validate(this); } /** * Builds instances of type {@link Integration Integration}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @NotThreadSafe public static class Builder { private static final long OPT_BIT_IS_DELETED = 0x1L; private static final long OPT_BIT_STEPS = 0x2L; private static final long OPT_BIT_FLOWS = 0x4L; private static final long OPT_BIT_CONNECTIONS = 0x8L; private static final long OPT_BIT_CONFIGURED_PROPERTIES = 0x10L; private static final long OPT_BIT_VERSION = 0x20L; private static final long OPT_BIT_CREATED_AT = 0x40L; private static final long OPT_BIT_UPDATED_AT = 0x80L; private static final long OPT_BIT_RESOURCES = 0x100L; private long optBits; private @Nullable String id; private boolean isDeleted; private List steps = new ArrayList(); private List flows = new ArrayList(); private List connections = new ArrayList(); private @Nullable String description; private Map properties = new LinkedHashMap(); private Map configuredProperties = new LinkedHashMap(); private int version; private long createdAt; private long updatedAt; private List tags = new ArrayList(); private @Nullable String name; private List resources = new ArrayList(); /** * Creates a builder for {@link Integration Integration} instances. */ public Builder() { if (!(this instanceof Integration.Builder)) { throw new UnsupportedOperationException("Use: new Integration.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithName} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithName instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.integration.IntegrationBase} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(IntegrationBase instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithConfiguredProperties} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithConfiguredProperties instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.integration.WithSteps} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithSteps instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithResources} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithResources instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithVersion} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithVersion instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.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 Integration.Builder createFrom(WithTags instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithResourceId} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithResourceId instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithModificationTimestamps} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithModificationTimestamps instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.WithConfigurationProperties} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(WithConfigurationProperties instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.integration.Integration} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder createFrom(Integration instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (Integration.Builder) this; } private void from(Object object) { long bits = 0; if (object instanceof WithName) { WithName instance = (WithName) object; String nameValue = instance.getName(); if (nameValue != null) { name(nameValue); } } if (object instanceof IntegrationBase) { IntegrationBase instance = (IntegrationBase) object; Optional descriptionOptional = instance.getDescription(); if (descriptionOptional.isPresent()) { description(descriptionOptional); } isDeleted(instance.isDeleted()); if ((bits & 0x1L) == 0) { addAllSteps(instance.getSteps()); bits |= 0x1L; } addAllFlows(instance.getFlows()); addAllConnections(instance.getConnections()); } if (object instanceof WithConfiguredProperties) { WithConfiguredProperties instance = (WithConfiguredProperties) object; putAllConfiguredProperties(instance.getConfiguredProperties()); } if (object instanceof WithSteps) { WithSteps instance = (WithSteps) object; if ((bits & 0x1L) == 0) { addAllSteps(instance.getSteps()); bits |= 0x1L; } } if (object instanceof WithResources) { WithResources instance = (WithResources) object; addAllResources(instance.getResources()); } if (object instanceof WithVersion) { WithVersion instance = (WithVersion) object; version(instance.getVersion()); } if (object instanceof WithTags) { WithTags instance = (WithTags) object; addAllTags(instance.getTags()); } if (object instanceof WithResourceId) { WithResourceId instance = (WithResourceId) object; Optional idOptional = instance.getId(); if (idOptional.isPresent()) { id(idOptional); } } if (object instanceof WithModificationTimestamps) { WithModificationTimestamps instance = (WithModificationTimestamps) object; createdAt(instance.getCreatedAt()); updatedAt(instance.getUpdatedAt()); } if (object instanceof WithConfigurationProperties) { WithConfigurationProperties instance = (WithConfigurationProperties) object; putAllProperties(instance.getProperties()); } } /** * Initializes the optional value {@link Integration#getId() id} to id. * @param id The value for id * @return {@code this} builder for chained invocation */ public final Integration.Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); return (Integration.Builder) this; } /** * Initializes the optional value {@link Integration#getId() id} to id. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @JsonProperty("id") public final Integration.Builder id(Optional id) { this.id = id.orElse(null); return (Integration.Builder) this; } /** * Initializes the value for the {@link Integration#isDeleted() isDeleted} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Integration#isDeleted() isDeleted}. * @param isDeleted The value for isDeleted * @return {@code this} builder for use in a chained invocation */ @JsonProperty("isDeleted") @JsonInclude(JsonInclude.Include.NON_DEFAULT) public final Integration.Builder isDeleted(boolean isDeleted) { this.isDeleted = isDeleted; optBits |= OPT_BIT_IS_DELETED; return (Integration.Builder) this; } /** * Adds one element to {@link Integration#getSteps() steps} list. * @param element A steps element * @return {@code this} builder for use in a chained invocation */ @Deprecated public final Integration.Builder addStep(Step element) { this.steps.add(Objects.requireNonNull(element, "steps element")); optBits |= OPT_BIT_STEPS; return (Integration.Builder) this; } /** * Adds elements to {@link Integration#getSteps() steps} list. * @param elements An array of steps elements * @return {@code this} builder for use in a chained invocation */ @Deprecated public final Integration.Builder addStep(Step... elements) { for (Step element : elements) { this.steps.add(Objects.requireNonNull(element, "steps element")); } optBits |= OPT_BIT_STEPS; return (Integration.Builder) this; } /** * Sets or replaces all elements for {@link Integration#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("steps") @Deprecated public final Integration.Builder steps(Iterable elements) { this.steps.clear(); return addAllSteps(elements); } /** * Adds elements to {@link Integration#getSteps() steps} list. * @param elements An iterable of steps elements * @return {@code this} builder for use in a chained invocation */ @Deprecated public final Integration.Builder addAllSteps(Iterable elements) { for (Step element : elements) { this.steps.add(Objects.requireNonNull(element, "steps element")); } optBits |= OPT_BIT_STEPS; return (Integration.Builder) this; } /** * Adds one element to {@link Integration#getFlows() flows} list. * @param element A flows element * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addFlow(Flow element) { this.flows.add(Objects.requireNonNull(element, "flows element")); optBits |= OPT_BIT_FLOWS; return (Integration.Builder) this; } /** * Adds elements to {@link Integration#getFlows() flows} list. * @param elements An array of flows elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addFlow(Flow... elements) { for (Flow element : elements) { this.flows.add(Objects.requireNonNull(element, "flows element")); } optBits |= OPT_BIT_FLOWS; return (Integration.Builder) this; } /** * Sets or replaces all elements for {@link Integration#getFlows() flows} list. * @param elements An iterable of flows elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("flows") public final Integration.Builder flows(Iterable elements) { this.flows.clear(); return addAllFlows(elements); } /** * Adds elements to {@link Integration#getFlows() flows} list. * @param elements An iterable of flows elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addAllFlows(Iterable elements) { for (Flow element : elements) { this.flows.add(Objects.requireNonNull(element, "flows element")); } optBits |= OPT_BIT_FLOWS; return (Integration.Builder) this; } /** * Adds one element to {@link Integration#getConnections() connections} list. * @param element A connections element * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addConnection(Connection element) { this.connections.add(Objects.requireNonNull(element, "connections element")); optBits |= OPT_BIT_CONNECTIONS; return (Integration.Builder) this; } /** * Adds elements to {@link Integration#getConnections() connections} list. * @param elements An array of connections elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addConnection(Connection... elements) { for (Connection element : elements) { this.connections.add(Objects.requireNonNull(element, "connections element")); } optBits |= OPT_BIT_CONNECTIONS; return (Integration.Builder) this; } /** * Sets or replaces all elements for {@link Integration#getConnections() connections} list. * @param elements An iterable of connections elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("connections") public final Integration.Builder connections(Iterable elements) { this.connections.clear(); return addAllConnections(elements); } /** * Adds elements to {@link Integration#getConnections() connections} list. * @param elements An iterable of connections elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addAllConnections(Iterable elements) { for (Connection element : elements) { this.connections.add(Objects.requireNonNull(element, "connections element")); } optBits |= OPT_BIT_CONNECTIONS; return (Integration.Builder) this; } /** * Initializes the optional value {@link Integration#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for chained invocation */ public final Integration.Builder description(String description) { this.description = Objects.requireNonNull(description, "description"); return (Integration.Builder) this; } /** * Initializes the optional value {@link Integration#getDescription() description} to description. * @param description The value for description * @return {@code this} builder for use in a chained invocation */ @JsonProperty("description") @JsonDeserialize(converter = OptionalStringTrimmingConverter.class) public final Integration.Builder description(Optional description) { this.description = description.orElse(null); return (Integration.Builder) this; } /** * Put one entry to the {@link Integration#getProperties() properties} map. * @param key The key in the properties map * @param value The associated value in the properties map * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putProperty(String key, ConfigurationProperty value) { this.properties.put( Objects.requireNonNull(key, "properties key"), Objects.requireNonNull(value, "properties value")); return (Integration.Builder) this; } /** * Put one entry to the {@link Integration#getProperties() properties} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putProperty(Map.Entry entry) { String k = entry.getKey(); ConfigurationProperty v = entry.getValue(); this.properties.put( Objects.requireNonNull(k, "properties key"), Objects.requireNonNull(v, "properties value")); return (Integration.Builder) this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link Integration#getProperties() properties} map. Nulls are not permitted * @param properties The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("properties") public final Integration.Builder properties(Map properties) { this.properties.clear(); return putAllProperties(properties); } /** * Put all mappings from the specified map as entries to {@link Integration#getProperties() properties} map. Nulls are not permitted * @param properties The entries that will be added to the properties map * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putAllProperties(Map properties) { for (Map.Entry entry : properties.entrySet()) { String k = entry.getKey(); ConfigurationProperty v = entry.getValue(); this.properties.put( Objects.requireNonNull(k, "properties key"), Objects.requireNonNull(v, "properties value")); } return (Integration.Builder) this; } /** * Put one entry to the {@link Integration#getConfiguredProperties() configuredProperties} map. * @param key The key in the configuredProperties map * @param value The associated value in the configuredProperties map * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putConfiguredProperty(String key, String value) { this.configuredProperties.put( Objects.requireNonNull(key, "configuredProperties key"), Objects.requireNonNull(value, "configuredProperties value")); optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return (Integration.Builder) this; } /** * Put one entry to the {@link Integration#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putConfiguredProperty(Map.Entry entry) { String k = entry.getKey(); String v = entry.getValue(); this.configuredProperties.put( Objects.requireNonNull(k, "configuredProperties key"), Objects.requireNonNull(v, "configuredProperties value")); optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return (Integration.Builder) this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link Integration#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param configuredProperties The entries that will be added to the configuredProperties map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("configuredProperties") public final Integration.Builder configuredProperties(Map configuredProperties) { this.configuredProperties.clear(); optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return putAllConfiguredProperties(configuredProperties); } /** * Put all mappings from the specified map as entries to {@link Integration#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param configuredProperties The entries that will be added to the configuredProperties map * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder putAllConfiguredProperties(Map configuredProperties) { for (Map.Entry entry : configuredProperties.entrySet()) { String k = entry.getKey(); String v = entry.getValue(); this.configuredProperties.put( Objects.requireNonNull(k, "configuredProperties key"), Objects.requireNonNull(v, "configuredProperties value")); } optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return (Integration.Builder) this; } /** * Initializes the value for the {@link Integration#getVersion() version} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Integration#getVersion() version}. * @param version The value for version * @return {@code this} builder for use in a chained invocation */ @JsonProperty("version") public final Integration.Builder version(int version) { this.version = version; optBits |= OPT_BIT_VERSION; return (Integration.Builder) this; } /** * Initializes the value for the {@link Integration#getCreatedAt() createdAt} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Integration#getCreatedAt() createdAt}. * @param createdAt The value for createdAt * @return {@code this} builder for use in a chained invocation */ @JsonProperty("createdAt") public final Integration.Builder createdAt(long createdAt) { this.createdAt = createdAt; optBits |= OPT_BIT_CREATED_AT; return (Integration.Builder) this; } /** * Initializes the value for the {@link Integration#getUpdatedAt() updatedAt} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link Integration#getUpdatedAt() updatedAt}. * @param updatedAt The value for updatedAt * @return {@code this} builder for use in a chained invocation */ @JsonProperty("updatedAt") public final Integration.Builder updatedAt(long updatedAt) { this.updatedAt = updatedAt; optBits |= OPT_BIT_UPDATED_AT; return (Integration.Builder) this; } /** * Adds one element to {@link Integration#getTags() tags} sortedSet. * @param element A tags element * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addTag(String element) { if (element != null) this.tags.add(element); return (Integration.Builder) this; } /** * Adds elements to {@link Integration#getTags() tags} sortedSet. * @param elements An array of tags elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addTag(String... elements) { for (String element : elements) { if (element != null) this.tags.add(element); } return (Integration.Builder) this; } /** * Sets or replaces all elements for {@link Integration#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 Integration.Builder tags(Iterable elements) { this.tags.clear(); return addAllTags(elements); } /** * Adds elements to {@link Integration#getTags() tags} sortedSet. * @param elements An iterable of tags elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addAllTags(Iterable elements) { for (String element : elements) { if (element != null) this.tags.add(element); } return (Integration.Builder) this; } /** * Initializes the value for the {@link Integration#getName() name} attribute. * @param name The value for name (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("name") @JsonDeserialize(converter = StringTrimmingConverter.class) public final Integration.Builder name(String name) { this.name = name; return (Integration.Builder) this; } /** * Adds one element to {@link Integration#getResources() resources} list. * @param element A resources element * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addResource(ResourceIdentifier element) { this.resources.add(Objects.requireNonNull(element, "resources element")); optBits |= OPT_BIT_RESOURCES; return (Integration.Builder) this; } /** * Adds elements to {@link Integration#getResources() resources} list. * @param elements An array of resources elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addResource(ResourceIdentifier... elements) { for (ResourceIdentifier element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } optBits |= OPT_BIT_RESOURCES; return (Integration.Builder) this; } /** * Sets or replaces all elements for {@link Integration#getResources() resources} list. * @param elements An iterable of resources elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("resources") public final Integration.Builder resources(Iterable elements) { this.resources.clear(); return addAllResources(elements); } /** * Adds elements to {@link Integration#getResources() resources} list. * @param elements An iterable of resources elements * @return {@code this} builder for use in a chained invocation */ public final Integration.Builder addAllResources(Iterable elements) { for (ResourceIdentifier element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } optBits |= OPT_BIT_RESOURCES; return (Integration.Builder) this; } /** * Builds a new {@link Integration Integration}. * @return An immutable instance of Integration * @throws java.lang.IllegalStateException if any required attributes are missing */ public Integration build() { return ImmutableIntegration.validate(new ImmutableIntegration(this)); } private boolean isDeletedIsSet() { return (optBits & OPT_BIT_IS_DELETED) != 0; } private boolean stepsIsSet() { return (optBits & OPT_BIT_STEPS) != 0; } private boolean flowsIsSet() { return (optBits & OPT_BIT_FLOWS) != 0; } private boolean connectionsIsSet() { return (optBits & OPT_BIT_CONNECTIONS) != 0; } private boolean configuredPropertiesIsSet() { return (optBits & OPT_BIT_CONFIGURED_PROPERTIES) != 0; } private boolean versionIsSet() { return (optBits & OPT_BIT_VERSION) != 0; } private boolean createdAtIsSet() { return (optBits & OPT_BIT_CREATED_AT) != 0; } private boolean updatedAtIsSet() { return (optBits & OPT_BIT_UPDATED_AT) != 0; } private boolean resourcesIsSet() { return (optBits & OPT_BIT_RESOURCES) != 0; } } 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); } private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map map) { switch (map.size()) { case 0: return Collections.emptyMap(); case 1: { Map.Entry e = map.entrySet().iterator().next(); K k = e.getKey(); V v = e.getValue(); if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, "value"); } if (skipNulls && (k == null || v == null)) { return Collections.emptyMap(); } return Collections.singletonMap(k, v); } default: { Map linkedMap = new LinkedHashMap(map.size()); if (skipNulls || checkNulls) { for (Map.Entry e : map.entrySet()) { K k = e.getKey(); V v = e.getValue(); if (skipNulls) { if (k == null || v == null) continue; } else if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, "value"); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy