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

io.syndesis.rest.v1.dto.ImmutableVConnectionConfiguration Maven / Gradle / Ivy

There is a newer version: 1.3.0-20180304
Show newest version
package io.syndesis.rest.v1.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;

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

* Use the builder to create immutable instances: * {@code ImmutableVConnectionConfiguration.builder()}. */ @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @Generated({"Immutables.generator", "VConnectionConfiguration"}) @Immutable @CheckReturnValue public final class ImmutableVConnectionConfiguration implements VConnectionConfiguration { private final String connectorId; private final String actionId; private final ImmutableMap options; private ImmutableVConnectionConfiguration( String connectorId, String actionId, ImmutableMap options) { this.connectorId = connectorId; this.actionId = actionId; this.options = options; } /** * @return The value of the {@code connectorId} attribute */ @JsonProperty("connectorId") @Override public String getConnectorId() { return connectorId; } /** * @return The value of the {@code actionId} attribute */ @JsonProperty("actionId") @Override public String getActionId() { return actionId; } /** * @return The value of the {@code options} attribute */ @JsonProperty("options") @Override public ImmutableMap getOptions() { return options; } /** * Copy the current immutable object by setting a value for the {@link VConnectionConfiguration#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 * @return A modified copy of the {@code this} object */ public final ImmutableVConnectionConfiguration withConnectorId(String value) { if (this.connectorId.equals(value)) return this; String newValue = Objects.requireNonNull(value, "connectorId"); return new ImmutableVConnectionConfiguration(newValue, this.actionId, this.options); } /** * Copy the current immutable object by setting a value for the {@link VConnectionConfiguration#getActionId() actionId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for actionId * @return A modified copy of the {@code this} object */ public final ImmutableVConnectionConfiguration withActionId(String value) { if (this.actionId.equals(value)) return this; String newValue = Objects.requireNonNull(value, "actionId"); return new ImmutableVConnectionConfiguration(this.connectorId, newValue, this.options); } /** * Copy the current immutable object by replacing the {@link VConnectionConfiguration#getOptions() options} 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 options map * @return A modified copy of {@code this} object */ public final ImmutableVConnectionConfiguration withOptions(Map entries) { if (this.options == entries) return this; ImmutableMap newValue = ImmutableMap.copyOf(entries); return new ImmutableVConnectionConfiguration(this.connectorId, this.actionId, newValue); } /** * This instance is equal to all instances of {@code ImmutableVConnectionConfiguration} 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 ImmutableVConnectionConfiguration && equalTo((ImmutableVConnectionConfiguration) another); } private boolean equalTo(ImmutableVConnectionConfiguration another) { return connectorId.equals(another.connectorId) && actionId.equals(another.actionId) && options.equals(another.options); } /** * Computes a hash code from attributes: {@code connectorId}, {@code actionId}, {@code options}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + connectorId.hashCode(); h += (h << 5) + actionId.hashCode(); h += (h << 5) + options.hashCode(); return h; } /** * Prints the immutable value {@code VConnectionConfiguration} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("VConnectionConfiguration") .omitNullValues() .add("connectorId", connectorId) .add("actionId", actionId) .add("options", options) .toString(); } /** * Creates an immutable copy of a {@link VConnectionConfiguration} 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 VConnectionConfiguration instance */ public static ImmutableVConnectionConfiguration copyOf(VConnectionConfiguration instance) { if (instance instanceof ImmutableVConnectionConfiguration) { return (ImmutableVConnectionConfiguration) instance; } return ImmutableVConnectionConfiguration.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableVConnectionConfiguration ImmutableVConnectionConfiguration}. * @return A new ImmutableVConnectionConfiguration builder */ public static ImmutableVConnectionConfiguration.Builder builder() { return new ImmutableVConnectionConfiguration.Builder(); } /** * Builds instances of type {@link ImmutableVConnectionConfiguration ImmutableVConnectionConfiguration}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ @NotThreadSafe public static final class Builder { private static final long INIT_BIT_CONNECTOR_ID = 0x1L; private static final long INIT_BIT_ACTION_ID = 0x2L; private long initBits = 0x3L; private @Nullable String connectorId; private @Nullable String actionId; private ImmutableMap.Builder options = ImmutableMap.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code VConnectionConfiguration} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(VConnectionConfiguration instance) { Objects.requireNonNull(instance, "instance"); connectorId(instance.getConnectorId()); actionId(instance.getActionId()); putAllOptions(instance.getOptions()); return this; } /** * Initializes the value for the {@link VConnectionConfiguration#getConnectorId() connectorId} attribute. * @param connectorId The value for connectorId * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("connectorId") public final Builder connectorId(String connectorId) { this.connectorId = Objects.requireNonNull(connectorId, "connectorId"); initBits &= ~INIT_BIT_CONNECTOR_ID; return this; } /** * Initializes the value for the {@link VConnectionConfiguration#getActionId() actionId} attribute. * @param actionId The value for actionId * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("actionId") public final Builder actionId(String actionId) { this.actionId = Objects.requireNonNull(actionId, "actionId"); initBits &= ~INIT_BIT_ACTION_ID; return this; } /** * Put one entry to the {@link VConnectionConfiguration#getOptions() options} map. * @param key The key in the options map * @param value The associated value in the options map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putOptions(String key, String value) { this.options.put(key, value); return this; } /** * Put one entry to the {@link VConnectionConfiguration#getOptions() options} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putOptions(Map.Entry entry) { this.options.put(entry); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link VConnectionConfiguration#getOptions() options} map. Nulls are not permitted * @param options The entries that will be added to the options map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("options") public final Builder options(Map options) { this.options = ImmutableMap.builder(); return putAllOptions(options); } /** * Put all mappings from the specified map as entries to {@link VConnectionConfiguration#getOptions() options} map. Nulls are not permitted * @param options The entries that will be added to the options map * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder putAllOptions(Map options) { this.options.putAll(options); return this; } /** * Builds a new {@link ImmutableVConnectionConfiguration ImmutableVConnectionConfiguration}. * @return An immutable instance of VConnectionConfiguration * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableVConnectionConfiguration build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableVConnectionConfiguration(connectorId, actionId, options.build()); } private String formatRequiredAttributesMessage() { List attributes = Lists.newArrayList(); if ((initBits & INIT_BIT_CONNECTOR_ID) != 0) attributes.add("connectorId"); if ((initBits & INIT_BIT_ACTION_ID) != 0) attributes.add("actionId"); return "Cannot build VConnectionConfiguration, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy