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

org.cloudfoundry.uaa.clients.ListClientsResponse Maven / Gradle / Ivy

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

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 clients request
 */
@Generated(from = "_ListClientsResponse", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ListClientsResponse extends org.cloudfoundry.uaa.clients._ListClientsResponse {
  private final Integer itemsPerPage;
  private final List resources;
  private final List schemas;
  private final Integer startIndex;
  private final Integer totalResults;

  private ListClientsResponse(ListClientsResponse.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 ListClientsResponse} 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 ListClientsResponse
        && equalTo(0, (ListClientsResponse) another);
  }

  private boolean equalTo(int synthetic, ListClientsResponse 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 ListClientsResponse} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "ListClientsResponse{"
        + "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 = "_ListClientsResponse", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.uaa.clients._ListClientsResponse {
    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 ListClientsResponse fromJson(Json json) {
    ListClientsResponse.Builder builder = ListClientsResponse.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 ListClientsResponse ListClientsResponse}.
   * 
   * ListClientsResponse.builder()
   *    .itemsPerPage(Integer) // required {@link ListClientsResponse#getItemsPerPage() itemsPerPage}
   *    .resource|addAllResources(Client) // {@link ListClientsResponse#getResources() resources} elements
   *    .schema|addAllSchemas(String) // {@link ListClientsResponse#getSchemas() schemas} elements
   *    .startIndex(Integer) // required {@link ListClientsResponse#getStartIndex() startIndex}
   *    .totalResults(Integer) // required {@link ListClientsResponse#getTotalResults() totalResults}
   *    .build();
   * 
* @return A new ListClientsResponse builder */ public static ListClientsResponse.Builder builder() { return new ListClientsResponse.Builder(); } /** * Builds instances of type {@link ListClientsResponse ListClientsResponse}. * 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 = "_ListClientsResponse", 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 ListClientsResponse} 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(ListClientsResponse instance) { return from((_ListClientsResponse) instance); } /** * Copy abstract value type {@code _ListClientsResponse} 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(_ListClientsResponse 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 ListClientsResponse#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 ListClientsResponse#getResources() resources} list. * @param element A resources element * @return {@code this} builder for use in a chained invocation */ public final Builder resource(Client element) { this.resources.add(Objects.requireNonNull(element, "resources element")); return this; } /** * Adds elements to {@link ListClientsResponse#getResources() resources} list. * @param elements An array of resources elements * @return {@code this} builder for use in a chained invocation */ public final Builder resources(Client... elements) { for (Client element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } return this; } /** * Sets or replaces all elements for {@link ListClientsResponse#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 ListClientsResponse#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 (Client element : elements) { this.resources.add(Objects.requireNonNull(element, "resources element")); } return this; } /** * Adds one element to {@link ListClientsResponse#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 ListClientsResponse#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 ListClientsResponse#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 ListClientsResponse#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 ListClientsResponse#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 ListClientsResponse#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 ListClientsResponse ListClientsResponse}. * @return An immutable instance of ListClientsResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public ListClientsResponse build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ListClientsResponse(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 ListClientsResponse, 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