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

org.cloudfoundry.uaa.groups.CreateGroupRequest Maven / Gradle / Ivy

There is a newer version: 5.12.2.RELEASE
Show newest version
package org.cloudfoundry.uaa.groups;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.uaa.IdentityZoned;
import org.immutables.value.Generated;

/**
 * The request payload for the create group
 */
@Generated(from = "_CreateGroupRequest", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class CreateGroupRequest extends org.cloudfoundry.uaa.groups._CreateGroupRequest {
  private final @Nullable String identityZoneId;
  private final @Nullable String identityZoneSubdomain;
  private final @Nullable String description;
  private final String displayName;
  private final @Nullable List members;

  private CreateGroupRequest(CreateGroupRequest.Builder builder) {
    this.identityZoneId = builder.identityZoneId;
    this.identityZoneSubdomain = builder.identityZoneSubdomain;
    this.description = builder.description;
    this.displayName = builder.displayName;
    this.members = builder.members == null ? null : createUnmodifiableList(true, builder.members);
  }

  /**
   * Returns the identity zone id
   * @return the identity zone id
   */
  @JsonProperty("identityZoneId")
  @JsonIgnore
  @Override
  public @Nullable String getIdentityZoneId() {
    return identityZoneId;
  }

  /**
   * Returns the identity zone subdomain
   * @return the identity zone subdomain
   */
  @JsonProperty("identityZoneSubdomain")
  @JsonIgnore
  @Override
  public @Nullable String getIdentityZoneSubdomain() {
    return identityZoneSubdomain;
  }

  /**
   * Human readable description of the group, displayed e.g. when approving scopes
   */
  @JsonProperty("description")
  @Override
  public @Nullable String getDescription() {
    return description;
  }

  /**
   * The identifier specified upon creation of the group, unique within the identity zone
   */
  @JsonProperty("displayName")
  @Override
  public String getDisplayName() {
    return displayName;
  }

  /**
   * Array of group members
   */
  @JsonProperty("members")
  @Override
  public @Nullable List getMembers() {
    return members;
  }

  /**
   * This instance is equal to all instances of {@code CreateGroupRequest} 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 CreateGroupRequest
        && equalTo(0, (CreateGroupRequest) another);
  }

  private boolean equalTo(int synthetic, CreateGroupRequest another) {
    return Objects.equals(identityZoneId, another.identityZoneId)
        && Objects.equals(identityZoneSubdomain, another.identityZoneSubdomain)
        && Objects.equals(description, another.description)
        && displayName.equals(another.displayName)
        && Objects.equals(members, another.members);
  }

  /**
   * Computes a hash code from attributes: {@code identityZoneId}, {@code identityZoneSubdomain}, {@code description}, {@code displayName}, {@code members}.
   * @return hashCode value
   */
  @Override
  public int hashCode() {
    int h = 5381;
    h += (h << 5) + Objects.hashCode(identityZoneId);
    h += (h << 5) + Objects.hashCode(identityZoneSubdomain);
    h += (h << 5) + Objects.hashCode(description);
    h += (h << 5) + displayName.hashCode();
    h += (h << 5) + Objects.hashCode(members);
    return h;
  }

  /**
   * Prints the immutable value {@code CreateGroupRequest} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "CreateGroupRequest{"
        + "identityZoneId=" + identityZoneId
        + ", identityZoneSubdomain=" + identityZoneSubdomain
        + ", description=" + description
        + ", displayName=" + displayName
        + ", members=" + members
        + "}";
  }

  /**
   * 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 = "_CreateGroupRequest", generator = "Immutables")
  @Deprecated
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.uaa.groups._CreateGroupRequest {
    String identityZoneId;
    String identityZoneSubdomain;
    String description;
    String displayName;
    List members = null;
    @JsonProperty("identityZoneId")
    @JsonIgnore
    public void setIdentityZoneId(@Nullable String identityZoneId) {
      this.identityZoneId = identityZoneId;
    }
    @JsonProperty("identityZoneSubdomain")
    @JsonIgnore
    public void setIdentityZoneSubdomain(@Nullable String identityZoneSubdomain) {
      this.identityZoneSubdomain = identityZoneSubdomain;
    }
    @JsonProperty("description")
    public void setDescription(@Nullable String description) {
      this.description = description;
    }
    @JsonProperty("displayName")
    public void setDisplayName(String displayName) {
      this.displayName = displayName;
    }
    @JsonProperty("members")
    public void setMembers(@Nullable List members) {
      this.members = members;
    }
    @Override
    public String getIdentityZoneId() { throw new UnsupportedOperationException(); }
    @Override
    public String getIdentityZoneSubdomain() { throw new UnsupportedOperationException(); }
    @Override
    public String getDescription() { throw new UnsupportedOperationException(); }
    @Override
    public String getDisplayName() { throw new UnsupportedOperationException(); }
    @Override
    public List getMembers() { 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 CreateGroupRequest fromJson(Json json) {
    CreateGroupRequest.Builder builder = CreateGroupRequest.builder();
    if (json.identityZoneId != null) {
      builder.identityZoneId(json.identityZoneId);
    }
    if (json.identityZoneSubdomain != null) {
      builder.identityZoneSubdomain(json.identityZoneSubdomain);
    }
    if (json.description != null) {
      builder.description(json.description);
    }
    if (json.displayName != null) {
      builder.displayName(json.displayName);
    }
    if (json.members != null) {
      builder.addAllMembers(json.members);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link CreateGroupRequest CreateGroupRequest}.
   * 
   * CreateGroupRequest.builder()
   *    .identityZoneId(String | null) // nullable {@link CreateGroupRequest#getIdentityZoneId() identityZoneId}
   *    .identityZoneSubdomain(String | null) // nullable {@link CreateGroupRequest#getIdentityZoneSubdomain() identityZoneSubdomain}
   *    .description(String | null) // nullable {@link CreateGroupRequest#getDescription() description}
   *    .displayName(String) // required {@link CreateGroupRequest#getDisplayName() displayName}
   *    .members(List&lt;MemberSummary&gt; | null) // nullable {@link CreateGroupRequest#getMembers() members}
   *    .build();
   * 
* @return A new CreateGroupRequest builder */ public static CreateGroupRequest.Builder builder() { return new CreateGroupRequest.Builder(); } /** * Builds instances of type {@link CreateGroupRequest CreateGroupRequest}. * 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 = "_CreateGroupRequest", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_DISPLAY_NAME = 0x1L; private long initBits = 0x1L; private String identityZoneId; private String identityZoneSubdomain; private String description; private String displayName; private List members = null; private Builder() { } /** * Fill a builder with attribute values from the provided {@code CreateGroupRequest} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(CreateGroupRequest instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Copy abstract value type {@code _CreateGroupRequest} instance into builder. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(_CreateGroupRequest instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.uaa.IdentityZoned} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(IdentityZoned instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { if (object instanceof org.cloudfoundry.uaa.groups._CreateGroupRequest) { org.cloudfoundry.uaa.groups._CreateGroupRequest instance = (org.cloudfoundry.uaa.groups._CreateGroupRequest) object; String descriptionValue = instance.getDescription(); if (descriptionValue != null) { description(descriptionValue); } displayName(instance.getDisplayName()); List membersValue = instance.getMembers(); if (membersValue != null) { addAllMembers(membersValue); } } if (object instanceof IdentityZoned) { IdentityZoned instance = (IdentityZoned) object; String identityZoneSubdomainValue = instance.getIdentityZoneSubdomain(); if (identityZoneSubdomainValue != null) { identityZoneSubdomain(identityZoneSubdomainValue); } String identityZoneIdValue = instance.getIdentityZoneId(); if (identityZoneIdValue != null) { identityZoneId(identityZoneIdValue); } } } /** * Initializes the value for the {@link CreateGroupRequest#getIdentityZoneId() identityZoneId} attribute. * @param identityZoneId The value for identityZoneId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder identityZoneId(@Nullable String identityZoneId) { this.identityZoneId = identityZoneId; return this; } /** * Initializes the value for the {@link CreateGroupRequest#getIdentityZoneSubdomain() identityZoneSubdomain} attribute. * @param identityZoneSubdomain The value for identityZoneSubdomain (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder identityZoneSubdomain(@Nullable String identityZoneSubdomain) { this.identityZoneSubdomain = identityZoneSubdomain; return this; } /** * Initializes the value for the {@link CreateGroupRequest#getDescription() description} attribute. * @param description The value for description (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder description(@Nullable String description) { this.description = description; return this; } /** * Initializes the value for the {@link CreateGroupRequest#getDisplayName() displayName} attribute. * @param displayName The value for displayName * @return {@code this} builder for use in a chained invocation */ public final Builder displayName(String displayName) { this.displayName = Objects.requireNonNull(displayName, "displayName"); initBits &= ~INIT_BIT_DISPLAY_NAME; return this; } /** * Adds one element to {@link CreateGroupRequest#getMembers() members} list. * @param element A members element * @return {@code this} builder for use in a chained invocation */ public final Builder member(MemberSummary element) { if (this.members == null) { this.members = new ArrayList(); } this.members.add(Objects.requireNonNull(element, "members element")); return this; } /** * Adds elements to {@link CreateGroupRequest#getMembers() members} list. * @param elements An array of members elements * @return {@code this} builder for use in a chained invocation */ public final Builder members(MemberSummary... elements) { if (this.members == null) { this.members = new ArrayList(); } for (MemberSummary element : elements) { this.members.add(Objects.requireNonNull(element, "members element")); } return this; } /** * Sets or replaces all elements for {@link CreateGroupRequest#getMembers() members} list. * @param elements An iterable of members elements * @return {@code this} builder for use in a chained invocation */ public final Builder members(@Nullable Iterable elements) { if (elements == null) { this.members = null; return this; } this.members = new ArrayList(); return addAllMembers(elements); } /** * Adds elements to {@link CreateGroupRequest#getMembers() members} list. * @param elements An iterable of members elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllMembers(Iterable elements) { Objects.requireNonNull(elements, "members element"); if (this.members == null) { this.members = new ArrayList(); } for (MemberSummary element : elements) { this.members.add(Objects.requireNonNull(element, "members element")); } return this; } /** * Builds a new {@link CreateGroupRequest CreateGroupRequest}. * @return An immutable instance of CreateGroupRequest * @throws java.lang.IllegalStateException if any required attributes are missing */ public CreateGroupRequest build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new CreateGroupRequest(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_DISPLAY_NAME) != 0) attributes.add("displayName"); return "Cannot build CreateGroupRequest, some of required attributes are not set " + attributes; } } 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<>(size); } 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); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy