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

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

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

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
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 UserActionsClient.AuthorizationAction}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableAuthorizationAction.builder()}. */ @Generated(from = "UserActionsClient.AuthorizationAction", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableAuthorizationAction implements UserActionsClient.AuthorizationAction { private final ImmutableList userRoles; private final ImmutableList allowedProcessNames; private ImmutableAuthorizationAction( ImmutableList userRoles, ImmutableList allowedProcessNames) { this.userRoles = userRoles; this.allowedProcessNames = allowedProcessNames; } /** * @return The value of the {@code userRoles} attribute */ @JsonProperty("userRoles") @Override public ImmutableList getUserRoles() { return userRoles; } /** * @return The value of the {@code allowedProcessNames} attribute */ @JsonProperty("allowedProcessNames") @Override public ImmutableList getAllowedProcessNames() { return allowedProcessNames; } /** * Copy the current immutable object with elements that replace the content of {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableAuthorizationAction withUserRoles(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAuthorizationAction(newValue, this.allowedProcessNames); } /** * Copy the current immutable object with elements that replace the content of {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of userRoles elements to set * @return A modified copy of {@code this} object */ public final ImmutableAuthorizationAction withUserRoles(Iterable elements) { if (this.userRoles == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAuthorizationAction(newValue, this.allowedProcessNames); } /** * Copy the current immutable object with elements that replace the content of {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ImmutableAuthorizationAction withAllowedProcessNames(String... elements) { ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAuthorizationAction(this.userRoles, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of allowedProcessNames elements to set * @return A modified copy of {@code this} object */ public final ImmutableAuthorizationAction withAllowedProcessNames(Iterable elements) { if (this.allowedProcessNames == elements) return this; ImmutableList newValue = ImmutableList.copyOf(elements); return new ImmutableAuthorizationAction(this.userRoles, newValue); } /** * This instance is equal to all instances of {@code ImmutableAuthorizationAction} 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 ImmutableAuthorizationAction && equalTo((ImmutableAuthorizationAction) another); } private boolean equalTo(ImmutableAuthorizationAction another) { return userRoles.equals(another.userRoles) && allowedProcessNames.equals(another.allowedProcessNames); } /** * Computes a hash code from attributes: {@code userRoles}, {@code allowedProcessNames}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + userRoles.hashCode(); h += (h << 5) + allowedProcessNames.hashCode(); return h; } /** * Prints the immutable value {@code AuthorizationAction} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("AuthorizationAction") .omitNullValues() .add("userRoles", userRoles) .add("allowedProcessNames", allowedProcessNames) .toString(); } /** * Utility type used to correctly read immutable object from JSON representation. * @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure */ @Generated(from = "UserActionsClient.AuthorizationAction", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements UserActionsClient.AuthorizationAction { @Nullable List userRoles = ImmutableList.of(); @Nullable List allowedProcessNames = ImmutableList.of(); @JsonProperty("userRoles") public void setUserRoles(List userRoles) { this.userRoles = userRoles; } @JsonProperty("allowedProcessNames") public void setAllowedProcessNames(List allowedProcessNames) { this.allowedProcessNames = allowedProcessNames; } @Override public List getUserRoles() { throw new UnsupportedOperationException(); } @Override public List getAllowedProcessNames() { throw new UnsupportedOperationException(); } } /** * @param json A JSON-bindable data structure * @return An immutable value type * @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure */ @Deprecated @JsonCreator(mode = JsonCreator.Mode.DELEGATING) static ImmutableAuthorizationAction fromJson(Json json) { ImmutableAuthorizationAction.Builder builder = ImmutableAuthorizationAction.builder(); if (json.userRoles != null) { builder.addAllUserRoles(json.userRoles); } if (json.allowedProcessNames != null) { builder.addAllAllowedProcessNames(json.allowedProcessNames); } return builder.build(); } /** * Creates an immutable copy of a {@link UserActionsClient.AuthorizationAction} 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 AuthorizationAction instance */ public static ImmutableAuthorizationAction copyOf(UserActionsClient.AuthorizationAction instance) { if (instance instanceof ImmutableAuthorizationAction) { return (ImmutableAuthorizationAction) instance; } return ImmutableAuthorizationAction.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableAuthorizationAction ImmutableAuthorizationAction}. *

   * ImmutableAuthorizationAction.builder()
   *    .addUserRoles|addAllUserRoles(String) // {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles} elements
   *    .addAllowedProcessNames|addAllAllowedProcessNames(String) // {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames} elements
   *    .build();
   * 
* @return A new ImmutableAuthorizationAction builder */ public static ImmutableAuthorizationAction.Builder builder() { return new ImmutableAuthorizationAction.Builder(); } /** * Builds instances of type {@link ImmutableAuthorizationAction ImmutableAuthorizationAction}. * 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 = "UserActionsClient.AuthorizationAction", generator = "Immutables") @NotThreadSafe public static final class Builder { private ImmutableList.Builder userRoles = ImmutableList.builder(); private ImmutableList.Builder allowedProcessNames = ImmutableList.builder(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code AuthorizationAction} 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(UserActionsClient.AuthorizationAction instance) { Objects.requireNonNull(instance, "instance"); addAllUserRoles(instance.getUserRoles()); addAllAllowedProcessNames(instance.getAllowedProcessNames()); return this; } /** * Adds one element to {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles} list. * @param element A userRoles element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUserRoles(String element) { this.userRoles.add(element); return this; } /** * Adds elements to {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles} list. * @param elements An array of userRoles elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addUserRoles(String... elements) { this.userRoles.add(elements); return this; } /** * Sets or replaces all elements for {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles} list. * @param elements An iterable of userRoles elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("userRoles") public final Builder userRoles(Iterable elements) { this.userRoles = ImmutableList.builder(); return addAllUserRoles(elements); } /** * Adds elements to {@link UserActionsClient.AuthorizationAction#getUserRoles() userRoles} list. * @param elements An iterable of userRoles elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllUserRoles(Iterable elements) { this.userRoles.addAll(elements); return this; } /** * Adds one element to {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames} list. * @param element A allowedProcessNames element * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllowedProcessNames(String element) { this.allowedProcessNames.add(element); return this; } /** * Adds elements to {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames} list. * @param elements An array of allowedProcessNames elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllowedProcessNames(String... elements) { this.allowedProcessNames.add(elements); return this; } /** * Sets or replaces all elements for {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames} list. * @param elements An iterable of allowedProcessNames elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("allowedProcessNames") public final Builder allowedProcessNames(Iterable elements) { this.allowedProcessNames = ImmutableList.builder(); return addAllAllowedProcessNames(elements); } /** * Adds elements to {@link UserActionsClient.AuthorizationAction#getAllowedProcessNames() allowedProcessNames} list. * @param elements An iterable of allowedProcessNames elements * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder addAllAllowedProcessNames(Iterable elements) { this.allowedProcessNames.addAll(elements); return this; } /** * Builds a new {@link ImmutableAuthorizationAction ImmutableAuthorizationAction}. * @return An immutable instance of AuthorizationAction * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableAuthorizationAction build() { return new ImmutableAuthorizationAction(userRoles.build(), allowedProcessNames.build()); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy