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

io.ingenieux.lambada.testing.ImmutableLambadaIdentity Maven / Gradle / Ivy

The newest version!
package io.ingenieux.lambada.testing;

import com.amazonaws.services.lambda.runtime.CognitoIdentity;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.Generated;

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

* Use the builder to create immutable instances: * {@code ImmutableLambadaIdentity.builder()}. */ @SuppressWarnings("all") @Generated({"Immutables.generator", "LambadaIdentity"}) public final class ImmutableLambadaIdentity implements LambadaIdentity { private final String identityId; private final String identityPoolId; private ImmutableLambadaIdentity(String identityId, String identityPoolId) { this.identityId = identityId; this.identityPoolId = identityPoolId; } /** * @return The value of the {@code identityId} attribute */ @Override public String getIdentityId() { return identityId; } /** * @return The value of the {@code identityPoolId} attribute */ @Override public String getIdentityPoolId() { return identityPoolId; } /** * Copy the current immutable object by setting a value for the {@link LambadaIdentity#getIdentityId() identityId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for identityId * @return A modified copy of the {@code this} object */ public final ImmutableLambadaIdentity withIdentityId(String value) { if (this.identityId.equals(value)) return this; return new ImmutableLambadaIdentity(Objects.requireNonNull(value, "identityId"), this.identityPoolId); } /** * Copy the current immutable object by setting a value for the {@link LambadaIdentity#getIdentityPoolId() identityPoolId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for identityPoolId * @return A modified copy of the {@code this} object */ public final ImmutableLambadaIdentity withIdentityPoolId(String value) { if (this.identityPoolId.equals(value)) return this; return new ImmutableLambadaIdentity(this.identityId, Objects.requireNonNull(value, "identityPoolId")); } /** * This instance is equal to all instances of {@code ImmutableLambadaIdentity} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof ImmutableLambadaIdentity && equalTo((ImmutableLambadaIdentity) another); } private boolean equalTo(ImmutableLambadaIdentity another) { return identityId.equals(another.identityId) && identityPoolId.equals(another.identityPoolId); } /** * Computes a hash code from attributes: {@code identityId}, {@code identityPoolId}. * @return hashCode value */ @Override public int hashCode() { int h = 31; h = h * 17 + identityId.hashCode(); h = h * 17 + identityPoolId.hashCode(); return h; } /** * Prints the immutable value {@code LambadaIdentity} with attribute values. * @return A string representation of the value */ @Override public String toString() { return "LambadaIdentity{" + "identityId=" + identityId + ", identityPoolId=" + identityPoolId + "}"; } /** * Creates an immutable copy of a {@link LambadaIdentity} 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 LambadaIdentity instance */ public static ImmutableLambadaIdentity copyOf(LambadaIdentity instance) { if (instance instanceof ImmutableLambadaIdentity) { return (ImmutableLambadaIdentity) instance; } return ImmutableLambadaIdentity.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableLambadaIdentity ImmutableLambadaIdentity}. * @return A new ImmutableLambadaIdentity builder */ public static ImmutableLambadaIdentity.Builder builder() { return new ImmutableLambadaIdentity.Builder(); } /** * Builds instances of type {@link ImmutableLambadaIdentity ImmutableLambadaIdentity}. * Initialize attributes and then invoke the {@link #build()} method to create an * immutable instance. *

{@code Builder} is not thread-safe and generally should not be stored in a field or collection, * but instead used immediately to create instances. */ public static final class Builder { private static final long INIT_BIT_IDENTITY_ID = 0x1L; private static final long INIT_BIT_IDENTITY_POOL_ID = 0x2L; private long initBits = 0x3; private String identityId; private String identityPoolId; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.amazonaws.services.lambda.runtime.CognitoIdentity} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(CognitoIdentity instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code io.ingenieux.lambada.testing.LambadaIdentity} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(LambadaIdentity instance) { Objects.requireNonNull(instance, "instance"); from((Object) instance); return this; } private void from(Object object) { if (object instanceof CognitoIdentity) { CognitoIdentity instance = (CognitoIdentity) object; identityPoolId(instance.getIdentityPoolId()); identityId(instance.getIdentityId()); } } /** * Initializes the value for the {@link LambadaIdentity#getIdentityId() identityId} attribute. * @param identityId The value for identityId * @return {@code this} builder for use in a chained invocation */ public final Builder identityId(String identityId) { this.identityId = Objects.requireNonNull(identityId, "identityId"); initBits &= ~INIT_BIT_IDENTITY_ID; return this; } /** * Initializes the value for the {@link LambadaIdentity#getIdentityPoolId() identityPoolId} attribute. * @param identityPoolId The value for identityPoolId * @return {@code this} builder for use in a chained invocation */ public final Builder identityPoolId(String identityPoolId) { this.identityPoolId = Objects.requireNonNull(identityPoolId, "identityPoolId"); initBits &= ~INIT_BIT_IDENTITY_POOL_ID; return this; } /** * Builds a new {@link ImmutableLambadaIdentity ImmutableLambadaIdentity}. * @return An immutable instance of LambadaIdentity * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableLambadaIdentity build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableLambadaIdentity(identityId, identityPoolId); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList(); if ((initBits & INIT_BIT_IDENTITY_ID) != 0) attributes.add("identityId"); if ((initBits & INIT_BIT_IDENTITY_POOL_ID) != 0) attributes.add("identityPoolId"); return "Cannot build LambadaIdentity, some of required attributes are not set " + attributes; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy