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

org.cloudfoundry.client.v3.isolationsegments.AddIsolationSegmentOrganizationEntitlementResponse Maven / Gradle / Ivy

There is a newer version: 5.12.2.RELEASE
Show newest version
package org.cloudfoundry.client.v3.isolationsegments;

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.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.client.v3.Link;
import org.cloudfoundry.client.v3.Relationship;
import org.immutables.value.Generated;

/**
 * The response payload for the Entitle one or more Organizations for an Isolation Segment operation
 */
@Generated(from = "_AddIsolationSegmentOrganizationEntitlementResponse", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class AddIsolationSegmentOrganizationEntitlementResponse
    extends org.cloudfoundry.client.v3.isolationsegments._AddIsolationSegmentOrganizationEntitlementResponse {
  private final @Nullable List data;
  private final @Nullable Map links;

  private AddIsolationSegmentOrganizationEntitlementResponse(AddIsolationSegmentOrganizationEntitlementResponse.Builder builder) {
    this.data = builder.data == null ? null : createUnmodifiableList(true, builder.data);
    this.links = builder.links == null ? null : createUnmodifiableMap(false, false, builder.links);
  }

  /**
   * The entitled organizations
   */
  @JsonProperty("data")
  @Override
  public @Nullable List getData() {
    return data;
  }

  /**
   * The links
   */
  @JsonProperty("links")
  @Override
  public @Nullable Map getLinks() {
    return links;
  }

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

  private boolean equalTo(int synthetic, AddIsolationSegmentOrganizationEntitlementResponse another) {
    return Objects.equals(data, another.data)
        && Objects.equals(links, another.links);
  }

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

  /**
   * Prints the immutable value {@code AddIsolationSegmentOrganizationEntitlementResponse} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "AddIsolationSegmentOrganizationEntitlementResponse{"
        + "data=" + data
        + ", links=" + links
        + "}";
  }

  /**
   * 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 = "_AddIsolationSegmentOrganizationEntitlementResponse", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json
      extends org.cloudfoundry.client.v3.isolationsegments._AddIsolationSegmentOrganizationEntitlementResponse {
    List data = null;
    Map links = null;
    @JsonProperty("data")
    public void setData(@Nullable List data) {
      this.data = data;
    }
    @JsonProperty("links")
    public void setLinks(@Nullable Map links) {
      this.links = links;
    }
    @Override
    public List getData() { throw new UnsupportedOperationException(); }
    @Override
    public Map getLinks() { 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 AddIsolationSegmentOrganizationEntitlementResponse fromJson(Json json) {
    AddIsolationSegmentOrganizationEntitlementResponse.Builder builder = AddIsolationSegmentOrganizationEntitlementResponse.builder();
    if (json.data != null) {
      builder.addAllData(json.data);
    }
    if (json.links != null) {
      builder.putAllLinks(json.links);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link AddIsolationSegmentOrganizationEntitlementResponse AddIsolationSegmentOrganizationEntitlementResponse}.
   * 
   * AddIsolationSegmentOrganizationEntitlementResponse.builder()
   *    .data(List&lt;org.cloudfoundry.client.v3.Relationship&gt; | null) // nullable {@link AddIsolationSegmentOrganizationEntitlementResponse#getData() data}
   *    .links(Map&lt;String, org.cloudfoundry.client.v3.Link&gt; | null) // nullable {@link AddIsolationSegmentOrganizationEntitlementResponse#getLinks() links}
   *    .build();
   * 
* @return A new AddIsolationSegmentOrganizationEntitlementResponse builder */ public static AddIsolationSegmentOrganizationEntitlementResponse.Builder builder() { return new AddIsolationSegmentOrganizationEntitlementResponse.Builder(); } /** * Builds instances of type {@link AddIsolationSegmentOrganizationEntitlementResponse AddIsolationSegmentOrganizationEntitlementResponse}. * 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 = "_AddIsolationSegmentOrganizationEntitlementResponse", generator = "Immutables") public static final class Builder { private List data = null; private Map links = null; private Builder() { } /** * Fill a builder with attribute values from the provided {@code AddIsolationSegmentOrganizationEntitlementResponse} 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(AddIsolationSegmentOrganizationEntitlementResponse instance) { return from((_AddIsolationSegmentOrganizationEntitlementResponse) instance); } /** * Copy abstract value type {@code _AddIsolationSegmentOrganizationEntitlementResponse} 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(_AddIsolationSegmentOrganizationEntitlementResponse instance) { Objects.requireNonNull(instance, "instance"); List dataValue = instance.getData(); if (dataValue != null) { addAllData(dataValue); } Map linksValue = instance.getLinks(); if (linksValue != null) { putAllLinks(linksValue); } return this; } /** * Adds one element to {@link AddIsolationSegmentOrganizationEntitlementResponse#getData() data} list. * @param element A data element * @return {@code this} builder for use in a chained invocation */ public final Builder data(Relationship element) { if (this.data == null) { this.data = new ArrayList(); } this.data.add(Objects.requireNonNull(element, "data element")); return this; } /** * Adds elements to {@link AddIsolationSegmentOrganizationEntitlementResponse#getData() data} list. * @param elements An array of data elements * @return {@code this} builder for use in a chained invocation */ public final Builder data(Relationship... elements) { if (this.data == null) { this.data = new ArrayList(); } for (Relationship element : elements) { this.data.add(Objects.requireNonNull(element, "data element")); } return this; } /** * Sets or replaces all elements for {@link AddIsolationSegmentOrganizationEntitlementResponse#getData() data} list. * @param elements An iterable of data elements * @return {@code this} builder for use in a chained invocation */ @JsonProperty("data") public final Builder data(@Nullable Iterable elements) { if (elements == null) { this.data = null; return this; } this.data = new ArrayList(); return addAllData(elements); } /** * Adds elements to {@link AddIsolationSegmentOrganizationEntitlementResponse#getData() data} list. * @param elements An iterable of data elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllData(Iterable elements) { Objects.requireNonNull(elements, "data element"); if (this.data == null) { this.data = new ArrayList(); } for (Relationship element : elements) { this.data.add(Objects.requireNonNull(element, "data element")); } return this; } /** * Put one entry to the {@link AddIsolationSegmentOrganizationEntitlementResponse#getLinks() links} map. * @param key The key in the links map * @param value The associated value in the links map * @return {@code this} builder for use in a chained invocation */ public final Builder link(String key, Link value) { if (this.links == null) { this.links = new LinkedHashMap(); } this.links.put(key, value); return this; } /** * Put one entry to the {@link AddIsolationSegmentOrganizationEntitlementResponse#getLinks() links} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ public final Builder link(Map.Entry entry) { if (this.links == null) { this.links = new LinkedHashMap(); } String k = entry.getKey(); Link v = entry.getValue(); this.links.put(k, v); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link AddIsolationSegmentOrganizationEntitlementResponse#getLinks() links} map. Nulls are not permitted as keys or values, but parameter itself can be null * @param entries The entries that will be added to the links map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("links") public final Builder links(@Nullable Map entries) { if (entries == null) { this.links = null; return this; } this.links = new LinkedHashMap(); return putAllLinks(entries); } /** * Put all mappings from the specified map as entries to {@link AddIsolationSegmentOrganizationEntitlementResponse#getLinks() links} map. Nulls are not permitted * @param entries The entries that will be added to the links map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllLinks(Map entries) { if (this.links == null) { this.links = new LinkedHashMap(); } for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Link v = e.getValue(); this.links.put(k, v); } return this; } /** * Builds a new {@link AddIsolationSegmentOrganizationEntitlementResponse AddIsolationSegmentOrganizationEntitlementResponse}. * @return An immutable instance of AddIsolationSegmentOrganizationEntitlementResponse * @throws java.lang.IllegalStateException if any required attributes are missing */ public AddIsolationSegmentOrganizationEntitlementResponse build() { return new AddIsolationSegmentOrganizationEntitlementResponse(this); } } 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); } } } private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map map) { switch (map.size()) { case 0: return Collections.emptyMap(); case 1: { Map.Entry e = map.entrySet().iterator().next(); K k = e.getKey(); V v = e.getValue(); if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } if (skipNulls && (k == null || v == null)) { return Collections.emptyMap(); } return Collections.singletonMap(k, v); } default: { Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1); if (skipNulls || checkNulls) { for (Map.Entry e : map.entrySet()) { K k = e.getKey(); V v = e.getValue(); if (skipNulls) { if (k == null || v == null) continue; } else if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy