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

org.cloudfoundry.uaa.users.ListUsersResponse Maven / Gradle / Ivy

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

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 java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.uaa.*;
import org.immutables.value.Generated;

/**
 * The response from the list users request
 */
@Generated(from = "_ListUsersResponse", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ListUsersResponse extends org.cloudfoundry.uaa.users._ListUsersResponse {
  private final Integer itemsPerPage;
  private final List resources;
  private final List schemas;
  private final Integer startIndex;
  private final Integer totalResults;

  private ListUsersResponse(ListUsersResponse.Builder builder) {
    this.itemsPerPage = builder.itemsPerPage;
    this.resources = createUnmodifiableList(true, builder.resources);
    this.schemas = createUnmodifiableList(true, builder.schemas);
    this.startIndex = builder.startIndex;
    this.totalResults = builder.totalResults;
  }

  /**
   * The itemsPerPage
   */
  @JsonProperty("itemsPerPage")
  @Override
  public Integer getItemsPerPage() {
    return itemsPerPage;
  }

  /**
   * The resources
   */
  @JsonProperty("resources")
  @Override
  public List getResources() {
    return resources;
  }

  /**
   * The schemas
   */
  @JsonProperty("schemas")
  @Override
  public List getSchemas() {
    return schemas;
  }

  /**
   * The startIndex
   */
  @JsonProperty("startIndex")
  @Override
  public Integer getStartIndex() {
    return startIndex;
  }

  /**
   * The total results
   */
  @JsonProperty("totalResults")
  @Override
  public Integer getTotalResults() {
    return totalResults;
  }

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

  private boolean equalTo(int synthetic, ListUsersResponse another) {
    return itemsPerPage.equals(another.itemsPerPage)
        && resources.equals(another.resources)
        && schemas.equals(another.schemas)
        && startIndex.equals(another.startIndex)
        && totalResults.equals(another.totalResults);
  }

  /**
   * Computes a hash code from attributes: {@code itemsPerPage}, {@code resources}, {@code schemas}, {@code startIndex}, {@code totalResults}.
   * @return hashCode value
   */
  @Override
  public int hashCode() {
    int h = 5381;
    h += (h << 5) + itemsPerPage.hashCode();
    h += (h << 5) + resources.hashCode();
    h += (h << 5) + schemas.hashCode();
    h += (h << 5) + startIndex.hashCode();
    h += (h << 5) + totalResults.hashCode();
    return h;
  }

  /**
   * Prints the immutable value {@code ListUsersResponse} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "ListUsersResponse{"
        + "itemsPerPage=" + itemsPerPage
        + ", resources=" + resources
        + ", schemas=" + schemas
        + ", startIndex=" + startIndex
        + ", totalResults=" + totalResults
        + "}";
  }

  /**
   * 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 = "_ListUsersResponse", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.uaa.users._ListUsersResponse {
    Integer itemsPerPage;
    List resources = Collections.emptyList();
    List schemas = Collections.emptyList();
    Integer startIndex;
    Integer totalResults;
    @JsonProperty("itemsPerPage")
    public void setItemsPerPage(Integer itemsPerPage) {
      this.itemsPerPage = itemsPerPage;
    }
    @JsonProperty("resources")
    public void setResources(List resources) {
      this.resources = resources;
    }
    @JsonProperty("schemas")
    public void setSchemas(List schemas) {
      this.schemas = schemas;
    }
    @JsonProperty("startIndex")
    public void setStartIndex(Integer startIndex) {
      this.startIndex = startIndex;
    }
    @JsonProperty("totalResults")
    public void setTotalResults(Integer totalResults) {
      this.totalResults = totalResults;
    }
    @Override
    public Integer getItemsPerPage() { throw new UnsupportedOperationException(); }
    @Override
    public List getResources() { throw new UnsupportedOperationException(); }
    @Override
    public List getSchemas() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getStartIndex() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getTotalResults() { 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 ListUsersResponse fromJson(Json json) {
    ListUsersResponse.Builder builder = ListUsersResponse.builder();
    if (json.itemsPerPage != null) {
      builder.itemsPerPage(json.itemsPerPage);
    }
    if (json.resources != null) {
      builder.addAllResources(json.resources);
    }
    if (json.schemas != null) {
      builder.addAllSchemas(json.schemas);
    }
    if (json.startIndex != null) {
      builder.startIndex(json.startIndex);
    }
    if (json.totalResults != null) {
      builder.totalResults(json.totalResults);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link ListUsersResponse ListUsersResponse}.
   * 
   * ListUsersResponse.builder()
   *    .itemsPerPage(Integer) // required {@link ListUsersResponse#getItemsPerPage() itemsPerPage}
   *    .resource|addAllResources(User) // {@link ListUsersResponse#getResources() resources} elements
   *    .schema|addAllSchemas(String) // {@link ListUsersResponse#getSchemas() schemas} elements
   *    .startIndex(Integer) // required {@link ListUsersResponse#getStartIndex() startIndex}
   *    .totalResults(Integer) // required {@link ListUsersResponse#getTotalResults() totalResults}
   *    .build();
   * 
* @return A new ListUsersResponse builder */ public static ListUsersResponse.Builder builder() { return new ListUsersResponse.Builder(); } /** * Builds instances of type {@link ListUsersResponse ListUsersResponse}. * 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 = "_ListUsersResponse", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_ITEMS_PER_PAGE = 0x1L; private static final long INIT_BIT_START_INDEX = 0x2L; private static final long INIT_BIT_TOTAL_RESULTS = 0x4L; private long initBits = 0x7L; private Integer itemsPerPage; private List resources = new ArrayList(); private List schemas = new ArrayList(); private Integer startIndex; private Integer totalResults; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ListUsersResponse} 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 */ public final Builder from(ListUsersResponse instance) { return from((_ListUsersResponse) instance); } /** * Copy abstract value type {@code _ListUsersResponse} instance into builder. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ final Builder from(_ListUsersResponse instance) { Objects.requireNonNull(instance, "instance"); itemsPerPage(instance.getItemsPerPage()); addAllResources(instance.getResources()); addAllSchemas(instance.getSchemas()); startIndex(instance.getStartIndex()); totalResults(instance.getTotalResults()); return this; } /** * Initializes the value for the {@link ListUsersResponse#getItemsPerPage() itemsPerPage} attribute. * @param itemsPerPage The value for itemsPerPage * @return {@code this} builder for use in a chained invocation */ @JsonProperty("itemsPerPage") public final Builder itemsPerPage(Integer itemsPerPage) { this.itemsPerPage = Objects.requireNonNull(itemsPerPage, "itemsPerPage"); initBits &= ~INIT_BIT_ITEMS_PER_PAGE; return this; } /** * Adds one element to {@link ListUsersResponse#getResources() resources} list. * @param element A resources element * @return {@code this} builder for use in a chained invocation */ public final Builder resource(User element) { this.resources.add(Objects.requireNonNull(element, "resources element")); return this; } /** * Adds elements to {@link ListUsersResponse#getResources() resources} list. * @param elements An array of resources elements * @return {@code this} builder for use in a chained invocation */ public final Builder resources(User... elements) { for (User element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } return this; } /** * Sets or replaces all elements for {@link ListUsersResponse#getResources() resources} list. * @param elements An iterable of resources elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("resources") public final Builder resources(Iterable elements) { this.resources.clear(); return addAllResources(elements); } /** * Adds elements to {@link ListUsersResponse#getResources() resources} list. * @param elements An iterable of resources elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllResources(Iterable elements) { for (User element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } return this; } /** * Adds one element to {@link ListUsersResponse#getSchemas() schemas} list. * @param element A schemas element * @return {@code this} builder for use in a chained invocation */ public final Builder schema(String element) { this.schemas.add(Objects.requireNonNull(element, "schemas element")); return this; } /** * Adds elements to {@link ListUsersResponse#getSchemas() schemas} list. * @param elements An array of schemas elements * @return {@code this} builder for use in a chained invocation */ public final Builder schemas(String... elements) { for (String element : elements) { this.schemas.add(Objects.requireNonNull(element, "schemas element")); } return this; } /** * Sets or replaces all elements for {@link ListUsersResponse#getSchemas() schemas} list. * @param elements An iterable of schemas elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("schemas") public final Builder schemas(Iterable elements) { this.schemas.clear(); return addAllSchemas(elements); } /** * Adds elements to {@link ListUsersResponse#getSchemas() schemas} list. * @param elements An iterable of schemas elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllSchemas(Iterable elements) { for (String element : elements) { this.schemas.add(Objects.requireNonNull(element, "schemas element")); } return this; } /** * Initializes the value for the {@link ListUsersResponse#getStartIndex() startIndex} attribute. * @param startIndex The value for startIndex * @return {@code this} builder for use in a chained invocation */ @JsonProperty("startIndex") public final Builder startIndex(Integer startIndex) { this.startIndex = Objects.requireNonNull(startIndex, "startIndex"); initBits &= ~INIT_BIT_START_INDEX; return this; } /** * Initializes the value for the {@link ListUsersResponse#getTotalResults() totalResults} attribute. * @param totalResults The value for totalResults * @return {@code this} builder for use in a chained invocation */ @JsonProperty("totalResults") public final Builder totalResults(Integer totalResults) { this.totalResults = Objects.requireNonNull(totalResults, "totalResults"); initBits &= ~INIT_BIT_TOTAL_RESULTS; return this; } /** * Builds a new {@link ListUsersResponse ListUsersResponse}. * @return An immutable instance of ListUsersResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public ListUsersResponse build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ListUsersResponse(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ITEMS_PER_PAGE) != 0) attributes.add("itemsPerPage"); if ((initBits & INIT_BIT_START_INDEX) != 0) attributes.add("startIndex"); if ((initBits & INIT_BIT_TOTAL_RESULTS) != 0) attributes.add("totalResults"); return "Cannot build ListUsersResponse, 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