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

io.syndesis.common.model.action.ImmutableConnectorDescriptor Maven / Gradle / Ivy

/*
 * 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.action;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.syndesis.common.model.DataShape;
import io.syndesis.common.model.WithConfiguredProperties;
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.Objects;
import java.util.Optional;
import java.util.Set;
import javax.annotation.CheckReturnValue;
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;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code new ConnectorDescriptor.Builder()}. * Use the static factory method to create immutable instances: * {@code ImmutableConnectorDescriptor.of()}. */ @Generated(from = "ConnectorDescriptor", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue final class ImmutableConnectorDescriptor implements ConnectorDescriptor { private final @Nullable DataShape inputDataShape; private final @Nullable DataShape outputDataShape; private final List propertyDefinitionSteps; private final Map configuredProperties; private final String connectorId; private final String camelConnectorGAV; private final String camelConnectorPrefix; private final @Nullable String componentScheme; private final @Nullable String connectorFactory; private final List connectorCustomizers; @SuppressWarnings("unchecked") // safe covariant cast private ImmutableConnectorDescriptor( Optional inputDataShape, Optional outputDataShape, Iterable propertyDefinitionSteps, Map configuredProperties, String connectorId, String camelConnectorGAV, String camelConnectorPrefix, Optional componentScheme, Optional connectorFactory, Iterable connectorCustomizers) { this.inputDataShape = inputDataShape.orElse(null); this.outputDataShape = outputDataShape.orElse(null); this.propertyDefinitionSteps = createUnmodifiableList(false, createSafeList(propertyDefinitionSteps, true, false)); this.configuredProperties = createUnmodifiableMap(true, false, configuredProperties); this.connectorId = connectorId; this.camelConnectorGAV = camelConnectorGAV; this.camelConnectorPrefix = camelConnectorPrefix; this.componentScheme = componentScheme.orElse(null); this.connectorFactory = connectorFactory.orElse(null); this.connectorCustomizers = createUnmodifiableList(false, createSafeList(connectorCustomizers, true, false)); this.initShim = null; } private ImmutableConnectorDescriptor(ImmutableConnectorDescriptor.Builder builder) { this.inputDataShape = builder.inputDataShape; this.outputDataShape = builder.outputDataShape; this.connectorId = builder.connectorId; this.camelConnectorGAV = builder.camelConnectorGAV; this.camelConnectorPrefix = builder.camelConnectorPrefix; this.componentScheme = builder.componentScheme; this.connectorFactory = builder.connectorFactory; if (builder.propertyDefinitionStepsIsSet()) { initShim.propertyDefinitionSteps(createUnmodifiableList(true, builder.propertyDefinitionSteps)); } if (builder.configuredPropertiesIsSet()) { initShim.configuredProperties(createUnmodifiableMap(false, false, builder.configuredProperties)); } if (builder.connectorCustomizersIsSet()) { initShim.connectorCustomizers(createUnmodifiableList(true, builder.connectorCustomizers)); } this.propertyDefinitionSteps = initShim.getPropertyDefinitionSteps(); this.configuredProperties = initShim.getConfiguredProperties(); this.connectorCustomizers = initShim.getConnectorCustomizers(); this.initShim = null; } private ImmutableConnectorDescriptor( ImmutableConnectorDescriptor original, @Nullable DataShape inputDataShape, @Nullable DataShape outputDataShape, List propertyDefinitionSteps, Map configuredProperties, String connectorId, String camelConnectorGAV, String camelConnectorPrefix, @Nullable String componentScheme, @Nullable String connectorFactory, List connectorCustomizers) { this.inputDataShape = inputDataShape; this.outputDataShape = outputDataShape; this.propertyDefinitionSteps = propertyDefinitionSteps; this.configuredProperties = configuredProperties; this.connectorId = connectorId; this.camelConnectorGAV = camelConnectorGAV; this.camelConnectorPrefix = camelConnectorPrefix; this.componentScheme = componentScheme; this.connectorFactory = connectorFactory; this.connectorCustomizers = connectorCustomizers; this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; @SuppressWarnings("Immutable") private transient volatile InitShim initShim = new InitShim(); @Generated(from = "ConnectorDescriptor", generator = "Immutables") private final class InitShim { private byte propertyDefinitionStepsBuildStage = STAGE_UNINITIALIZED; private List propertyDefinitionSteps; List getPropertyDefinitionSteps() { if (propertyDefinitionStepsBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (propertyDefinitionStepsBuildStage == STAGE_UNINITIALIZED) { propertyDefinitionStepsBuildStage = STAGE_INITIALIZING; this.propertyDefinitionSteps = createUnmodifiableList(false, createSafeList(getPropertyDefinitionStepsInitialize(), true, false)); propertyDefinitionStepsBuildStage = STAGE_INITIALIZED; } return this.propertyDefinitionSteps; } void propertyDefinitionSteps(List propertyDefinitionSteps) { this.propertyDefinitionSteps = propertyDefinitionSteps; propertyDefinitionStepsBuildStage = STAGE_INITIALIZED; } private byte configuredPropertiesBuildStage = STAGE_UNINITIALIZED; private Map configuredProperties; 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 byte connectorCustomizersBuildStage = STAGE_UNINITIALIZED; private List connectorCustomizers; List getConnectorCustomizers() { if (connectorCustomizersBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage()); if (connectorCustomizersBuildStage == STAGE_UNINITIALIZED) { connectorCustomizersBuildStage = STAGE_INITIALIZING; this.connectorCustomizers = createUnmodifiableList(false, createSafeList(getConnectorCustomizersInitialize(), true, false)); connectorCustomizersBuildStage = STAGE_INITIALIZED; } return this.connectorCustomizers; } void connectorCustomizers(List connectorCustomizers) { this.connectorCustomizers = connectorCustomizers; connectorCustomizersBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (propertyDefinitionStepsBuildStage == STAGE_INITIALIZING) attributes.add("propertyDefinitionSteps"); if (configuredPropertiesBuildStage == STAGE_INITIALIZING) attributes.add("configuredProperties"); if (connectorCustomizersBuildStage == STAGE_INITIALIZING) attributes.add("connectorCustomizers"); return "Cannot build ConnectorDescriptor, attribute initializers form cycle " + attributes; } } private List getPropertyDefinitionStepsInitialize() { return ConnectorDescriptor.super.getPropertyDefinitionSteps(); } private Map getConfiguredPropertiesInitialize() { return ConnectorDescriptor.super.getConfiguredProperties(); } private List getConnectorCustomizersInitialize() { return ConnectorDescriptor.super.getConnectorCustomizers(); } /** * @return The value of the {@code inputDataShape} attribute */ @JsonProperty("inputDataShape") @Override public Optional getInputDataShape() { return Optional.ofNullable(inputDataShape); } /** * @return The value of the {@code outputDataShape} attribute */ @JsonProperty("outputDataShape") @Override public Optional getOutputDataShape() { return Optional.ofNullable(outputDataShape); } /** * @return The value of the {@code propertyDefinitionSteps} attribute */ @JsonProperty("propertyDefinitionSteps") @Override public List getPropertyDefinitionSteps() { InitShim shim = this.initShim; return shim != null ? shim.getPropertyDefinitionSteps() : this.propertyDefinitionSteps; } /** * @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 connectorId} attribute */ @JsonProperty("connectorId") @Override public String getConnectorId() { return connectorId; } /** * @return The value of the {@code camelConnectorGAV} attribute */ @JsonProperty("camelConnectorGAV") @Override public String getCamelConnectorGAV() { return camelConnectorGAV; } /** * @return The value of the {@code camelConnectorPrefix} attribute */ @JsonProperty("camelConnectorPrefix") @Override public String getCamelConnectorPrefix() { return camelConnectorPrefix; } /** * @return The value of the {@code componentScheme} attribute */ @JsonProperty("componentScheme") @Override public Optional getComponentScheme() { return Optional.ofNullable(componentScheme); } /** * @return The value of the {@code connectorFactory} attribute */ @JsonProperty("connectorFactory") @Override public Optional getConnectorFactory() { return Optional.ofNullable(connectorFactory); } /** * @return The value of the {@code connectorCustomizers} attribute */ @JsonProperty("connectorCustomizers") @Override public List getConnectorCustomizers() { InitShim shim = this.initShim; return shim != null ? shim.getConnectorCustomizers() : this.connectorCustomizers; } /** * Copy the current immutable object by setting a present value for the optional {@link ConnectorDescriptor#getInputDataShape() inputDataShape} attribute. * @param value The value for inputDataShape * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withInputDataShape(DataShape value) { @Nullable DataShape newValue = Objects.requireNonNull(value, "inputDataShape"); if (this.inputDataShape == newValue) return this; return validate(new ImmutableConnectorDescriptor( this, newValue, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting an optional value for the {@link ConnectorDescriptor#getInputDataShape() inputDataShape} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for inputDataShape * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ImmutableConnectorDescriptor withInputDataShape(Optional optional) { @Nullable DataShape value = optional.orElse(null); if (this.inputDataShape == value) return this; return validate(new ImmutableConnectorDescriptor( this, value, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a present value for the optional {@link ConnectorDescriptor#getOutputDataShape() outputDataShape} attribute. * @param value The value for outputDataShape * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withOutputDataShape(DataShape value) { @Nullable DataShape newValue = Objects.requireNonNull(value, "outputDataShape"); if (this.outputDataShape == newValue) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, newValue, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting an optional value for the {@link ConnectorDescriptor#getOutputDataShape() outputDataShape} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for outputDataShape * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ImmutableConnectorDescriptor withOutputDataShape(Optional optional) { @Nullable DataShape value = optional.orElse(null); if (this.outputDataShape == value) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, value, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object with elements that replace the content of {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withPropertyDefinitionSteps(ActionDescriptor.ActionDescriptorStep... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, newValue, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object with elements that replace the content of {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of propertyDefinitionSteps elements to set * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withPropertyDefinitionSteps(Iterable elements) { if (this.propertyDefinitionSteps == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, newValue, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by replacing the {@link ConnectorDescriptor#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 ImmutableConnectorDescriptor withConfiguredProperties(Map entries) { if (this.configuredProperties == entries) return this; Map newValue = createUnmodifiableMap(true, false, entries); return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, newValue, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a value for the {@link ConnectorDescriptor#getConnectorId() connectorId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for connectorId (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConnectorDescriptor withConnectorId(String value) { if (Objects.equals(this.connectorId, value)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, value, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a value for the {@link ConnectorDescriptor#getCamelConnectorGAV() camelConnectorGAV} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for camelConnectorGAV (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConnectorDescriptor withCamelConnectorGAV(String value) { if (Objects.equals(this.camelConnectorGAV, value)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, value, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a value for the {@link ConnectorDescriptor#getCamelConnectorPrefix() camelConnectorPrefix} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for camelConnectorPrefix (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableConnectorDescriptor withCamelConnectorPrefix(String value) { if (Objects.equals(this.camelConnectorPrefix, value)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, value, this.componentScheme, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a present value for the optional {@link ConnectorDescriptor#getComponentScheme() componentScheme} attribute. * @param value The value for componentScheme * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withComponentScheme(String value) { @Nullable String newValue = Objects.requireNonNull(value, "componentScheme"); if (Objects.equals(this.componentScheme, newValue)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, newValue, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting an optional value for the {@link ConnectorDescriptor#getComponentScheme() componentScheme} 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 componentScheme * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withComponentScheme(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.componentScheme, value)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, value, this.connectorFactory, this.connectorCustomizers)); } /** * Copy the current immutable object by setting a present value for the optional {@link ConnectorDescriptor#getConnectorFactory() connectorFactory} attribute. * @param value The value for connectorFactory * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withConnectorFactory(String value) { @Nullable String newValue = Objects.requireNonNull(value, "connectorFactory"); if (Objects.equals(this.connectorFactory, newValue)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, newValue, this.connectorCustomizers)); } /** * Copy the current immutable object by setting an optional value for the {@link ConnectorDescriptor#getConnectorFactory() connectorFactory} 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 connectorFactory * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withConnectorFactory(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.connectorFactory, value)) return this; return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, value, this.connectorCustomizers)); } /** * Copy the current immutable object with elements that replace the content of {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withConnectorCustomizers(String... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, newValue)); } /** * Copy the current immutable object with elements that replace the content of {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of connectorCustomizers elements to set * @return A modified copy of {@code this} object */ public final ImmutableConnectorDescriptor withConnectorCustomizers(Iterable elements) { if (this.connectorCustomizers == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ImmutableConnectorDescriptor( this, this.inputDataShape, this.outputDataShape, this.propertyDefinitionSteps, this.configuredProperties, this.connectorId, this.camelConnectorGAV, this.camelConnectorPrefix, this.componentScheme, this.connectorFactory, newValue)); } /** * This instance is equal to all instances of {@code ImmutableConnectorDescriptor} 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 ImmutableConnectorDescriptor && equalTo((ImmutableConnectorDescriptor) another); } private boolean equalTo(ImmutableConnectorDescriptor another) { return Objects.equals(inputDataShape, another.inputDataShape) && Objects.equals(outputDataShape, another.outputDataShape) && propertyDefinitionSteps.equals(another.propertyDefinitionSteps) && configuredProperties.equals(another.configuredProperties) && Objects.equals(connectorId, another.connectorId) && Objects.equals(camelConnectorGAV, another.camelConnectorGAV) && Objects.equals(camelConnectorPrefix, another.camelConnectorPrefix) && Objects.equals(componentScheme, another.componentScheme) && Objects.equals(connectorFactory, another.connectorFactory) && connectorCustomizers.equals(another.connectorCustomizers); } /** * Computes a hash code from attributes: {@code inputDataShape}, {@code outputDataShape}, {@code propertyDefinitionSteps}, {@code configuredProperties}, {@code connectorId}, {@code camelConnectorGAV}, {@code camelConnectorPrefix}, {@code componentScheme}, {@code connectorFactory}, {@code connectorCustomizers}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + Objects.hashCode(inputDataShape); h += (h << 5) + Objects.hashCode(outputDataShape); h += (h << 5) + propertyDefinitionSteps.hashCode(); h += (h << 5) + configuredProperties.hashCode(); h += (h << 5) + Objects.hashCode(connectorId); h += (h << 5) + Objects.hashCode(camelConnectorGAV); h += (h << 5) + Objects.hashCode(camelConnectorPrefix); h += (h << 5) + Objects.hashCode(componentScheme); h += (h << 5) + Objects.hashCode(connectorFactory); h += (h << 5) + connectorCustomizers.hashCode(); return h; } /** * Prints the immutable value {@code ConnectorDescriptor} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ConnectorDescriptor{"); if (inputDataShape != null) { builder.append("inputDataShape=").append(inputDataShape); } if (outputDataShape != null) { if (builder.length() > 20) builder.append(", "); builder.append("outputDataShape=").append(outputDataShape); } if (builder.length() > 20) builder.append(", "); builder.append("propertyDefinitionSteps=").append(propertyDefinitionSteps); builder.append(", "); builder.append("configuredProperties=").append(configuredProperties); if (connectorId != null) { builder.append(", "); builder.append("connectorId=").append(connectorId); } if (camelConnectorGAV != null) { builder.append(", "); builder.append("camelConnectorGAV=").append(camelConnectorGAV); } if (camelConnectorPrefix != null) { builder.append(", "); builder.append("camelConnectorPrefix=").append(camelConnectorPrefix); } if (componentScheme != null) { builder.append(", "); builder.append("componentScheme=").append(componentScheme); } if (connectorFactory != null) { builder.append(", "); builder.append("connectorFactory=").append(connectorFactory); } builder.append(", "); builder.append("connectorCustomizers=").append(connectorCustomizers); return builder.append("}").toString(); } /** * Construct a new immutable {@code ConnectorDescriptor} instance. * @param inputDataShape The value for the {@code inputDataShape} attribute * @param outputDataShape The value for the {@code outputDataShape} attribute * @param propertyDefinitionSteps The value for the {@code propertyDefinitionSteps} attribute * @param configuredProperties The value for the {@code configuredProperties} attribute * @param connectorId The value for the {@code connectorId} attribute * @param camelConnectorGAV The value for the {@code camelConnectorGAV} attribute * @param camelConnectorPrefix The value for the {@code camelConnectorPrefix} attribute * @param componentScheme The value for the {@code componentScheme} attribute * @param connectorFactory The value for the {@code connectorFactory} attribute * @param connectorCustomizers The value for the {@code connectorCustomizers} attribute * @return An immutable ConnectorDescriptor instance */ public static ConnectorDescriptor of(Optional inputDataShape, Optional outputDataShape, List propertyDefinitionSteps, Map configuredProperties, String connectorId, String camelConnectorGAV, String camelConnectorPrefix, Optional componentScheme, Optional connectorFactory, List connectorCustomizers) { return of(inputDataShape, outputDataShape, (Iterable) propertyDefinitionSteps, configuredProperties, connectorId, camelConnectorGAV, camelConnectorPrefix, componentScheme, connectorFactory, (Iterable) connectorCustomizers); } /** * Construct a new immutable {@code ConnectorDescriptor} instance. * @param inputDataShape The value for the {@code inputDataShape} attribute * @param outputDataShape The value for the {@code outputDataShape} attribute * @param propertyDefinitionSteps The value for the {@code propertyDefinitionSteps} attribute * @param configuredProperties The value for the {@code configuredProperties} attribute * @param connectorId The value for the {@code connectorId} attribute * @param camelConnectorGAV The value for the {@code camelConnectorGAV} attribute * @param camelConnectorPrefix The value for the {@code camelConnectorPrefix} attribute * @param componentScheme The value for the {@code componentScheme} attribute * @param connectorFactory The value for the {@code connectorFactory} attribute * @param connectorCustomizers The value for the {@code connectorCustomizers} attribute * @return An immutable ConnectorDescriptor instance */ public static ConnectorDescriptor of(Optional inputDataShape, Optional outputDataShape, Iterable propertyDefinitionSteps, Map configuredProperties, String connectorId, String camelConnectorGAV, String camelConnectorPrefix, Optional componentScheme, Optional connectorFactory, Iterable connectorCustomizers) { return validate(new ImmutableConnectorDescriptor(inputDataShape, outputDataShape, propertyDefinitionSteps, configuredProperties, connectorId, camelConnectorGAV, camelConnectorPrefix, componentScheme, connectorFactory, connectorCustomizers)); } private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); private static ImmutableConnectorDescriptor validate(ImmutableConnectorDescriptor instance) { Set> constraintViolations = validator.validate(instance); if (!constraintViolations.isEmpty()) { throw new ConstraintViolationException(constraintViolations); } return instance; } /** * Creates an immutable copy of a {@link ConnectorDescriptor} 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 ConnectorDescriptor instance */ public static ConnectorDescriptor copyOf(ConnectorDescriptor instance) { if (instance instanceof ImmutableConnectorDescriptor) { return (ImmutableConnectorDescriptor) instance; } return new ConnectorDescriptor.Builder() .createFrom(instance) .build(); } private Object readResolve() throws ObjectStreamException { return validate(this); } /** * Builds instances of type {@link ConnectorDescriptor ConnectorDescriptor}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @Generated(from = "ConnectorDescriptor", generator = "Immutables") @NotThreadSafe public static class Builder { private static final long OPT_BIT_PROPERTY_DEFINITION_STEPS = 0x1L; private static final long OPT_BIT_CONFIGURED_PROPERTIES = 0x2L; private static final long OPT_BIT_CONNECTOR_CUSTOMIZERS = 0x4L; private long optBits; private @Nullable DataShape inputDataShape; private @Nullable DataShape outputDataShape; private List propertyDefinitionSteps = new ArrayList(); private Map configuredProperties = new LinkedHashMap(); private @Nullable String connectorId; private @Nullable String camelConnectorGAV; private @Nullable String camelConnectorPrefix; private @Nullable String componentScheme; private @Nullable String connectorFactory; private List connectorCustomizers = new ArrayList(); /** * Creates a builder for {@link ConnectorDescriptor ConnectorDescriptor} instances. *

     * new ConnectorDescriptor.Builder()
     *    .inputDataShape(io.syndesis.common.model.DataShape) // optional {@link ConnectorDescriptor#getInputDataShape() inputDataShape}
     *    .outputDataShape(io.syndesis.common.model.DataShape) // optional {@link ConnectorDescriptor#getOutputDataShape() outputDataShape}
     *    .addPropertyDefinitionStep|addAllPropertyDefinitionSteps(io.syndesis.common.model.action.ActionDescriptor.ActionDescriptorStep) // {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps} elements
     *    .putConfiguredProperty|putAllConfiguredProperties(String => String) // {@link ConnectorDescriptor#getConfiguredProperties() configuredProperties} mappings
     *    .connectorId(String | null) // nullable {@link ConnectorDescriptor#getConnectorId() connectorId}
     *    .camelConnectorGAV(String | null) // nullable {@link ConnectorDescriptor#getCamelConnectorGAV() camelConnectorGAV}
     *    .camelConnectorPrefix(String | null) // nullable {@link ConnectorDescriptor#getCamelConnectorPrefix() camelConnectorPrefix}
     *    .componentScheme(String) // optional {@link ConnectorDescriptor#getComponentScheme() componentScheme}
     *    .connectorFactory(String) // optional {@link ConnectorDescriptor#getConnectorFactory() connectorFactory}
     *    .addConnectorCustomizer|addAllConnectorCustomizers(String) // {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers} elements
     *    .build();
     * 
*/ public Builder() { if (!(this instanceof ConnectorDescriptor.Builder)) { throw new UnsupportedOperationException("Use: new ConnectorDescriptor.Builder()"); } } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.action.ConnectorDescriptor} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder createFrom(ConnectorDescriptor instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConnectorDescriptor.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 */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder createFrom(WithConfiguredProperties instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConnectorDescriptor.Builder) this; } /** * Fill a builder with attribute values from the provided {@code io.syndesis.common.model.action.ActionDescriptor} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder createFrom(ActionDescriptor instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return (ConnectorDescriptor.Builder) this; } private void from(Object object) { if (object instanceof ConnectorDescriptor) { ConnectorDescriptor instance = (ConnectorDescriptor) object; Optional componentSchemeOptional = instance.getComponentScheme(); if (componentSchemeOptional.isPresent()) { componentScheme(componentSchemeOptional); } Optional connectorFactoryOptional = instance.getConnectorFactory(); if (connectorFactoryOptional.isPresent()) { connectorFactory(connectorFactoryOptional); } addAllConnectorCustomizers(instance.getConnectorCustomizers()); String connectorIdValue = instance.getConnectorId(); if (connectorIdValue != null) { connectorId(connectorIdValue); } String camelConnectorPrefixValue = instance.getCamelConnectorPrefix(); if (camelConnectorPrefixValue != null) { camelConnectorPrefix(camelConnectorPrefixValue); } String camelConnectorGAVValue = instance.getCamelConnectorGAV(); if (camelConnectorGAVValue != null) { camelConnectorGAV(camelConnectorGAVValue); } } if (object instanceof WithConfiguredProperties) { WithConfiguredProperties instance = (WithConfiguredProperties) object; putAllConfiguredProperties(instance.getConfiguredProperties()); } if (object instanceof ActionDescriptor) { ActionDescriptor instance = (ActionDescriptor) object; Optional inputDataShapeOptional = instance.getInputDataShape(); if (inputDataShapeOptional.isPresent()) { inputDataShape(inputDataShapeOptional); } Optional outputDataShapeOptional = instance.getOutputDataShape(); if (outputDataShapeOptional.isPresent()) { outputDataShape(outputDataShapeOptional); } addAllPropertyDefinitionSteps(instance.getPropertyDefinitionSteps()); } } /** * Initializes the optional value {@link ConnectorDescriptor#getInputDataShape() inputDataShape} to inputDataShape. * @param inputDataShape The value for inputDataShape * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder inputDataShape(DataShape inputDataShape) { this.inputDataShape = Objects.requireNonNull(inputDataShape, "inputDataShape"); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getInputDataShape() inputDataShape} to inputDataShape. * @param inputDataShape The value for inputDataShape * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("inputDataShape") public final ConnectorDescriptor.Builder inputDataShape(Optional inputDataShape) { this.inputDataShape = inputDataShape.orElse(null); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getOutputDataShape() outputDataShape} to outputDataShape. * @param outputDataShape The value for outputDataShape * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder outputDataShape(DataShape outputDataShape) { this.outputDataShape = Objects.requireNonNull(outputDataShape, "outputDataShape"); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getOutputDataShape() outputDataShape} to outputDataShape. * @param outputDataShape The value for outputDataShape * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("outputDataShape") public final ConnectorDescriptor.Builder outputDataShape(Optional outputDataShape) { this.outputDataShape = outputDataShape.orElse(null); return (ConnectorDescriptor.Builder) this; } /** * Adds one element to {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps} list. * @param element A propertyDefinitionSteps element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addPropertyDefinitionStep(ActionDescriptor.ActionDescriptorStep element) { this.propertyDefinitionSteps.add(Objects.requireNonNull(element, "propertyDefinitionSteps element")); optBits |= OPT_BIT_PROPERTY_DEFINITION_STEPS; return (ConnectorDescriptor.Builder) this; } /** * Adds elements to {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps} list. * @param elements An array of propertyDefinitionSteps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addPropertyDefinitionSteps(ActionDescriptor.ActionDescriptorStep... elements) { for (ActionDescriptor.ActionDescriptorStep element : elements) { this.propertyDefinitionSteps.add(Objects.requireNonNull(element, "propertyDefinitionSteps element")); } optBits |= OPT_BIT_PROPERTY_DEFINITION_STEPS; return (ConnectorDescriptor.Builder) this; } /** * Sets or replaces all elements for {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps} list. * @param elements An iterable of propertyDefinitionSteps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("propertyDefinitionSteps") public final ConnectorDescriptor.Builder propertyDefinitionSteps(Iterable elements) { this.propertyDefinitionSteps.clear(); return addAllPropertyDefinitionSteps(elements); } /** * Adds elements to {@link ConnectorDescriptor#getPropertyDefinitionSteps() propertyDefinitionSteps} list. * @param elements An iterable of propertyDefinitionSteps elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addAllPropertyDefinitionSteps(Iterable elements) { for (ActionDescriptor.ActionDescriptorStep element : elements) { this.propertyDefinitionSteps.add(Objects.requireNonNull(element, "propertyDefinitionSteps element")); } optBits |= OPT_BIT_PROPERTY_DEFINITION_STEPS; return (ConnectorDescriptor.Builder) this; } /** * Put one entry to the {@link ConnectorDescriptor#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 */ @CanIgnoreReturnValue public final ConnectorDescriptor.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 (ConnectorDescriptor.Builder) this; } /** * Put one entry to the {@link ConnectorDescriptor#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.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 (ConnectorDescriptor.Builder) this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link ConnectorDescriptor#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param entries The entries that will be added to the configuredProperties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("configuredProperties") public final ConnectorDescriptor.Builder configuredProperties(Map entries) { this.configuredProperties.clear(); optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return putAllConfiguredProperties(entries); } /** * Put all mappings from the specified map as entries to {@link ConnectorDescriptor#getConfiguredProperties() configuredProperties} map. Nulls are not permitted * @param entries The entries that will be added to the configuredProperties map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder putAllConfiguredProperties(Map entries) { for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); String v = e.getValue(); this.configuredProperties.put( Objects.requireNonNull(k, "configuredProperties key"), Objects.requireNonNull(v, "configuredProperties value")); } optBits |= OPT_BIT_CONFIGURED_PROPERTIES; return (ConnectorDescriptor.Builder) this; } /** * Initializes the value for the {@link ConnectorDescriptor#getConnectorId() connectorId} attribute. * @param connectorId The value for connectorId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("connectorId") public final ConnectorDescriptor.Builder connectorId(String connectorId) { this.connectorId = connectorId; return (ConnectorDescriptor.Builder) this; } /** * Initializes the value for the {@link ConnectorDescriptor#getCamelConnectorGAV() camelConnectorGAV} attribute. * @param camelConnectorGAV The value for camelConnectorGAV (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("camelConnectorGAV") public final ConnectorDescriptor.Builder camelConnectorGAV(String camelConnectorGAV) { this.camelConnectorGAV = camelConnectorGAV; return (ConnectorDescriptor.Builder) this; } /** * Initializes the value for the {@link ConnectorDescriptor#getCamelConnectorPrefix() camelConnectorPrefix} attribute. * @param camelConnectorPrefix The value for camelConnectorPrefix (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("camelConnectorPrefix") public final ConnectorDescriptor.Builder camelConnectorPrefix(String camelConnectorPrefix) { this.camelConnectorPrefix = camelConnectorPrefix; return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getComponentScheme() componentScheme} to componentScheme. * @param componentScheme The value for componentScheme * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder componentScheme(String componentScheme) { this.componentScheme = Objects.requireNonNull(componentScheme, "componentScheme"); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getComponentScheme() componentScheme} to componentScheme. * @param componentScheme The value for componentScheme * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("componentScheme") public final ConnectorDescriptor.Builder componentScheme(Optional componentScheme) { this.componentScheme = componentScheme.orElse(null); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getConnectorFactory() connectorFactory} to connectorFactory. * @param connectorFactory The value for connectorFactory * @return {@code this} builder for chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder connectorFactory(String connectorFactory) { this.connectorFactory = Objects.requireNonNull(connectorFactory, "connectorFactory"); return (ConnectorDescriptor.Builder) this; } /** * Initializes the optional value {@link ConnectorDescriptor#getConnectorFactory() connectorFactory} to connectorFactory. * @param connectorFactory The value for connectorFactory * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("connectorFactory") public final ConnectorDescriptor.Builder connectorFactory(Optional connectorFactory) { this.connectorFactory = connectorFactory.orElse(null); return (ConnectorDescriptor.Builder) this; } /** * Adds one element to {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers} list. * @param element A connectorCustomizers element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addConnectorCustomizer(String element) { this.connectorCustomizers.add(Objects.requireNonNull(element, "connectorCustomizers element")); optBits |= OPT_BIT_CONNECTOR_CUSTOMIZERS; return (ConnectorDescriptor.Builder) this; } /** * Adds elements to {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers} list. * @param elements An array of connectorCustomizers elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addConnectorCustomizers(String... elements) { for (String element : elements) { this.connectorCustomizers.add(Objects.requireNonNull(element, "connectorCustomizers element")); } optBits |= OPT_BIT_CONNECTOR_CUSTOMIZERS; return (ConnectorDescriptor.Builder) this; } /** * Sets or replaces all elements for {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers} list. * @param elements An iterable of connectorCustomizers elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("connectorCustomizers") public final ConnectorDescriptor.Builder connectorCustomizers(Iterable elements) { this.connectorCustomizers.clear(); return addAllConnectorCustomizers(elements); } /** * Adds elements to {@link ConnectorDescriptor#getConnectorCustomizers() connectorCustomizers} list. * @param elements An iterable of connectorCustomizers elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final ConnectorDescriptor.Builder addAllConnectorCustomizers(Iterable elements) { for (String element : elements) { this.connectorCustomizers.add(Objects.requireNonNull(element, "connectorCustomizers element")); } optBits |= OPT_BIT_CONNECTOR_CUSTOMIZERS; return (ConnectorDescriptor.Builder) this; } /** * Builds a new {@link ConnectorDescriptor ConnectorDescriptor}. * @return An immutable instance of ConnectorDescriptor * @throws java.lang.IllegalStateException if any required attributes are missing */ public ConnectorDescriptor build() { return ImmutableConnectorDescriptor.validate(new ImmutableConnectorDescriptor(this)); } private boolean propertyDefinitionStepsIsSet() { return (optBits & OPT_BIT_PROPERTY_DEFINITION_STEPS) != 0; } private boolean configuredPropertiesIsSet() { return (optBits & OPT_BIT_CONFIGURED_PROPERTIES) != 0; } private boolean connectorCustomizersIsSet() { return (optBits & OPT_BIT_CONNECTOR_CUSTOMIZERS) != 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 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 - 2025 Weber Informatics LLC | Privacy Policy