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

io.thestencil.iam.api.ImmutableRemoteIntegration Maven / Gradle / Ivy

There is a newer version: 1.148.40
Show newest version
package io.thestencil.iam.api;

import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableRemoteIntegration.builder()}. */ @Generated(from = "RemoteIntegration", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableRemoteIntegration implements RemoteIntegration { private final String host; private final String path; private final String protocol; private final Integer port; private ImmutableRemoteIntegration(String host, String path, String protocol, Integer port) { this.host = host; this.path = path; this.protocol = protocol; this.port = port; } /** * @return The value of the {@code host} attribute */ @Override public String getHost() { return host; } /** * @return The value of the {@code path} attribute */ @Override public String getPath() { return path; } /** * @return The value of the {@code protocol} attribute */ @Override public String getProtocol() { return protocol; } /** * @return The value of the {@code port} attribute */ @Override public Integer getPort() { return port; } /** * Copy the current immutable object by setting a value for the {@link RemoteIntegration#getHost() host} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for host * @return A modified copy of the {@code this} object */ public final ImmutableRemoteIntegration withHost(String value) { String newValue = Objects.requireNonNull(value, "host"); if (this.host.equals(newValue)) return this; return new ImmutableRemoteIntegration(newValue, this.path, this.protocol, this.port); } /** * Copy the current immutable object by setting a value for the {@link RemoteIntegration#getPath() path} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for path * @return A modified copy of the {@code this} object */ public final ImmutableRemoteIntegration withPath(String value) { String newValue = Objects.requireNonNull(value, "path"); if (this.path.equals(newValue)) return this; return new ImmutableRemoteIntegration(this.host, newValue, this.protocol, this.port); } /** * Copy the current immutable object by setting a value for the {@link RemoteIntegration#getProtocol() protocol} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for protocol * @return A modified copy of the {@code this} object */ public final ImmutableRemoteIntegration withProtocol(String value) { String newValue = Objects.requireNonNull(value, "protocol"); if (this.protocol.equals(newValue)) return this; return new ImmutableRemoteIntegration(this.host, this.path, newValue, this.port); } /** * Copy the current immutable object by setting a value for the {@link RemoteIntegration#getPort() port} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for port * @return A modified copy of the {@code this} object */ public final ImmutableRemoteIntegration withPort(Integer value) { Integer newValue = Objects.requireNonNull(value, "port"); if (this.port.equals(newValue)) return this; return new ImmutableRemoteIntegration(this.host, this.path, this.protocol, newValue); } /** * This instance is equal to all instances of {@code ImmutableRemoteIntegration} 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 ImmutableRemoteIntegration && equalTo((ImmutableRemoteIntegration) another); } private boolean equalTo(ImmutableRemoteIntegration another) { return host.equals(another.host) && path.equals(another.path) && protocol.equals(another.protocol) && port.equals(another.port); } /** * Computes a hash code from attributes: {@code host}, {@code path}, {@code protocol}, {@code port}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + host.hashCode(); h += (h << 5) + path.hashCode(); h += (h << 5) + protocol.hashCode(); h += (h << 5) + port.hashCode(); return h; } /** * Prints the immutable value {@code RemoteIntegration} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("RemoteIntegration") .omitNullValues() .add("host", host) .add("path", path) .add("protocol", protocol) .add("port", port) .toString(); } /** * Creates an immutable copy of a {@link RemoteIntegration} 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 RemoteIntegration instance */ public static ImmutableRemoteIntegration copyOf(RemoteIntegration instance) { if (instance instanceof ImmutableRemoteIntegration) { return (ImmutableRemoteIntegration) instance; } return ImmutableRemoteIntegration.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableRemoteIntegration ImmutableRemoteIntegration}. *

   * ImmutableRemoteIntegration.builder()
   *    .host(String) // required {@link RemoteIntegration#getHost() host}
   *    .path(String) // required {@link RemoteIntegration#getPath() path}
   *    .protocol(String) // required {@link RemoteIntegration#getProtocol() protocol}
   *    .port(Integer) // required {@link RemoteIntegration#getPort() port}
   *    .build();
   * 
* @return A new ImmutableRemoteIntegration builder */ public static ImmutableRemoteIntegration.Builder builder() { return new ImmutableRemoteIntegration.Builder(); } /** * Builds instances of type {@link ImmutableRemoteIntegration ImmutableRemoteIntegration}. * 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 = "RemoteIntegration", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_HOST = 0x1L; private static final long INIT_BIT_PATH = 0x2L; private static final long INIT_BIT_PROTOCOL = 0x4L; private static final long INIT_BIT_PORT = 0x8L; private long initBits = 0xfL; private @Nullable String host; private @Nullable String path; private @Nullable String protocol; private @Nullable Integer port; private Builder() { } /** * Fill a builder with attribute values from the provided {@code RemoteIntegration} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(RemoteIntegration instance) { Objects.requireNonNull(instance, "instance"); host(instance.getHost()); path(instance.getPath()); protocol(instance.getProtocol()); port(instance.getPort()); return this; } /** * Initializes the value for the {@link RemoteIntegration#getHost() host} attribute. * @param host The value for host * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder host(String host) { this.host = Objects.requireNonNull(host, "host"); initBits &= ~INIT_BIT_HOST; return this; } /** * Initializes the value for the {@link RemoteIntegration#getPath() path} attribute. * @param path The value for path * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder path(String path) { this.path = Objects.requireNonNull(path, "path"); initBits &= ~INIT_BIT_PATH; return this; } /** * Initializes the value for the {@link RemoteIntegration#getProtocol() protocol} attribute. * @param protocol The value for protocol * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder protocol(String protocol) { this.protocol = Objects.requireNonNull(protocol, "protocol"); initBits &= ~INIT_BIT_PROTOCOL; return this; } /** * Initializes the value for the {@link RemoteIntegration#getPort() port} attribute. * @param port The value for port * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder port(Integer port) { this.port = Objects.requireNonNull(port, "port"); initBits &= ~INIT_BIT_PORT; return this; } /** * Builds a new {@link ImmutableRemoteIntegration ImmutableRemoteIntegration}. * @return An immutable instance of RemoteIntegration * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableRemoteIntegration build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableRemoteIntegration(host, path, protocol, port); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_HOST) != 0) attributes.add("host"); if ((initBits & INIT_BIT_PATH) != 0) attributes.add("path"); if ((initBits & INIT_BIT_PROTOCOL) != 0) attributes.add("protocol"); if ((initBits & INIT_BIT_PORT) != 0) attributes.add("port"); return "Cannot build RemoteIntegration, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy