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

org.cloudfoundry.client.v3.serviceinstances.ServiceInstanceResource Maven / Gradle / Ivy

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

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
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.*;
import org.cloudfoundry.client.v3.LastOperation;
import org.cloudfoundry.client.v3.MaintenanceInfo;
import org.cloudfoundry.client.v3.Metadata;
import org.cloudfoundry.client.v3.Resource;
import org.immutables.value.Generated;

/**
 * The resource response payload for the List Service Instances operation
 */
@Generated(from = "_ServiceInstanceResource", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ServiceInstanceResource
    extends org.cloudfoundry.client.v3.serviceinstances._ServiceInstanceResource {
  private final String createdAt;
  private final String id;
  private final Map links;
  private final @Nullable String updatedAt;
  private final @Nullable String dashboardUrl;
  private final @Nullable LastOperation lastOperation;
  private final @Nullable MaintenanceInfo maintenanceInfo;
  private final @Nullable Metadata metadata;
  private final String name;
  private final @Nullable ServiceInstanceRelationships relationships;
  private final @Nullable String routeServiceUrl;
  private final @Nullable String syslogDrainUrl;
  private final @Nullable List tags;
  private final @Nullable ServiceInstanceType type;
  private final @Nullable Boolean updateAvailable;

  private ServiceInstanceResource(ServiceInstanceResource.Builder builder) {
    this.createdAt = builder.createdAt;
    this.id = builder.id;
    this.links = createUnmodifiableMap(false, false, builder.links);
    this.updatedAt = builder.updatedAt;
    this.dashboardUrl = builder.dashboardUrl;
    this.lastOperation = builder.lastOperation;
    this.maintenanceInfo = builder.maintenanceInfo;
    this.metadata = builder.metadata;
    this.name = builder.name;
    this.relationships = builder.relationships;
    this.routeServiceUrl = builder.routeServiceUrl;
    this.syslogDrainUrl = builder.syslogDrainUrl;
    this.tags = builder.tags == null ? null : createUnmodifiableList(true, builder.tags);
    this.type = builder.type;
    this.updateAvailable = builder.updateAvailable;
  }

  /**
   * When the resource was created
   */
  @JsonProperty("created_at")
  @Override
  public String getCreatedAt() {
    return createdAt;
  }

  /**
   * The resource's id
   */
  @JsonProperty("guid")
  @Override
  public String getId() {
    return id;
  }

  /**
   * Links to related resources and actions for the resource
   */
  @JsonProperty("links")
  @Override
  public Map getLinks() {
    return links;
  }

  /**
   * When the resource was last updated
   */
  @JsonProperty("updated_at")
  @Override
  public @Nullable String getUpdatedAt() {
    return updatedAt;
  }

  /**
   * The dashboard url
   */
  @JsonProperty("dashboard_url")
  @Override
  public @Nullable String getDashboardUrl() {
    return dashboardUrl;
  }

  /**
   * The last operation
   */
  @JsonProperty("last_operation")
  @Override
  public @Nullable LastOperation getLastOperation() {
    return lastOperation;
  }

  /**
   * The maintenance info
   */
  @JsonProperty("maintenance_info")
  @Override
  public @Nullable MaintenanceInfo getMaintenanceInfo() {
    return maintenanceInfo;
  }

  /**
   * The metadata
   */
  @JsonProperty("metadata")
  @Override
  public @Nullable Metadata getMetadata() {
    return metadata;
  }

  /**
   * The name
   */
  @JsonProperty("name")
  @Override
  public String getName() {
    return name;
  }

  /**
   * The relationships
   */
  @JsonProperty("relationships")
  @Override
  public @Nullable ServiceInstanceRelationships getRelationships() {
    return relationships;
  }

  /**
   * The route service url
   */
  @JsonProperty("route_service_url")
  @Override
  public @Nullable String getRouteServiceUrl() {
    return routeServiceUrl;
  }

  /**
   * The syslog drain url
   */
  @JsonProperty("syslog_drain_url")
  @Override
  public @Nullable String getSyslogDrainUrl() {
    return syslogDrainUrl;
  }

  /**
   * A list of tags for the service instance
   */
  @JsonProperty("tags")
  @Override
  public @Nullable List getTags() {
    return tags;
  }

  /**
   * The type of the service instance
   */
  @JsonProperty("type")
  @Override
  public @Nullable ServiceInstanceType getType() {
    return type;
  }

  /**
   * Whether or not an upgrade of this service instance is available on the current Service Plan
   */
  @JsonProperty("upgrade_available")
  @Override
  public @Nullable Boolean getUpdateAvailable() {
    return updateAvailable;
  }

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

  private boolean equalTo(int synthetic, ServiceInstanceResource another) {
    return createdAt.equals(another.createdAt)
        && id.equals(another.id)
        && links.equals(another.links)
        && Objects.equals(updatedAt, another.updatedAt)
        && Objects.equals(dashboardUrl, another.dashboardUrl)
        && Objects.equals(lastOperation, another.lastOperation)
        && Objects.equals(maintenanceInfo, another.maintenanceInfo)
        && Objects.equals(metadata, another.metadata)
        && name.equals(another.name)
        && Objects.equals(relationships, another.relationships)
        && Objects.equals(routeServiceUrl, another.routeServiceUrl)
        && Objects.equals(syslogDrainUrl, another.syslogDrainUrl)
        && Objects.equals(tags, another.tags)
        && Objects.equals(type, another.type)
        && Objects.equals(updateAvailable, another.updateAvailable);
  }

  /**
   * Computes a hash code from attributes: {@code createdAt}, {@code id}, {@code links}, {@code updatedAt}, {@code dashboardUrl}, {@code lastOperation}, {@code maintenanceInfo}, {@code metadata}, {@code name}, {@code relationships}, {@code routeServiceUrl}, {@code syslogDrainUrl}, {@code tags}, {@code type}, {@code updateAvailable}.
   * @return hashCode value
   */
  @Override
  public int hashCode() {
    int h = 5381;
    h += (h << 5) + createdAt.hashCode();
    h += (h << 5) + id.hashCode();
    h += (h << 5) + links.hashCode();
    h += (h << 5) + Objects.hashCode(updatedAt);
    h += (h << 5) + Objects.hashCode(dashboardUrl);
    h += (h << 5) + Objects.hashCode(lastOperation);
    h += (h << 5) + Objects.hashCode(maintenanceInfo);
    h += (h << 5) + Objects.hashCode(metadata);
    h += (h << 5) + name.hashCode();
    h += (h << 5) + Objects.hashCode(relationships);
    h += (h << 5) + Objects.hashCode(routeServiceUrl);
    h += (h << 5) + Objects.hashCode(syslogDrainUrl);
    h += (h << 5) + Objects.hashCode(tags);
    h += (h << 5) + Objects.hashCode(type);
    h += (h << 5) + Objects.hashCode(updateAvailable);
    return h;
  }

  /**
   * Prints the immutable value {@code ServiceInstanceResource} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "ServiceInstanceResource{"
        + "createdAt=" + createdAt
        + ", id=" + id
        + ", links=" + links
        + ", updatedAt=" + updatedAt
        + ", dashboardUrl=" + dashboardUrl
        + ", lastOperation=" + lastOperation
        + ", maintenanceInfo=" + maintenanceInfo
        + ", metadata=" + metadata
        + ", name=" + name
        + ", relationships=" + relationships
        + ", routeServiceUrl=" + routeServiceUrl
        + ", syslogDrainUrl=" + syslogDrainUrl
        + ", tags=" + tags
        + ", type=" + type
        + ", updateAvailable=" + updateAvailable
        + "}";
  }

  /**
   * 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 = "_ServiceInstanceResource", generator = "Immutables")
  @Deprecated
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.client.v3.serviceinstances._ServiceInstanceResource {
    String createdAt;
    String id;
    Map links = Collections.emptyMap();
    String updatedAt;
    String dashboardUrl;
    LastOperation lastOperation;
    MaintenanceInfo maintenanceInfo;
    Metadata metadata;
    String name;
    ServiceInstanceRelationships relationships;
    String routeServiceUrl;
    String syslogDrainUrl;
    List tags = null;
    ServiceInstanceType type;
    Boolean updateAvailable;
    @JsonProperty("created_at")
    public void setCreatedAt(String createdAt) {
      this.createdAt = createdAt;
    }
    @JsonProperty("guid")
    public void setId(String id) {
      this.id = id;
    }
    @JsonProperty("links")
    public void setLinks(Map links) {
      this.links = links;
    }
    @JsonProperty("updated_at")
    public void setUpdatedAt(@Nullable String updatedAt) {
      this.updatedAt = updatedAt;
    }
    @JsonProperty("dashboard_url")
    public void setDashboardUrl(@Nullable String dashboardUrl) {
      this.dashboardUrl = dashboardUrl;
    }
    @JsonProperty("last_operation")
    public void setLastOperation(@Nullable LastOperation lastOperation) {
      this.lastOperation = lastOperation;
    }
    @JsonProperty("maintenance_info")
    public void setMaintenanceInfo(@Nullable MaintenanceInfo maintenanceInfo) {
      this.maintenanceInfo = maintenanceInfo;
    }
    @JsonProperty("metadata")
    public void setMetadata(@Nullable Metadata metadata) {
      this.metadata = metadata;
    }
    @JsonProperty("name")
    public void setName(String name) {
      this.name = name;
    }
    @JsonProperty("relationships")
    public void setRelationships(@Nullable ServiceInstanceRelationships relationships) {
      this.relationships = relationships;
    }
    @JsonProperty("route_service_url")
    public void setRouteServiceUrl(@Nullable String routeServiceUrl) {
      this.routeServiceUrl = routeServiceUrl;
    }
    @JsonProperty("syslog_drain_url")
    public void setSyslogDrainUrl(@Nullable String syslogDrainUrl) {
      this.syslogDrainUrl = syslogDrainUrl;
    }
    @JsonProperty("tags")
    public void setTags(@Nullable List tags) {
      this.tags = tags;
    }
    @JsonProperty("type")
    public void setType(@Nullable ServiceInstanceType type) {
      this.type = type;
    }
    @JsonProperty("upgrade_available")
    public void setUpdateAvailable(@Nullable Boolean updateAvailable) {
      this.updateAvailable = updateAvailable;
    }
    @Override
    public String getCreatedAt() { throw new UnsupportedOperationException(); }
    @Override
    public String getId() { throw new UnsupportedOperationException(); }
    @Override
    public Map getLinks() { throw new UnsupportedOperationException(); }
    @Override
    public String getUpdatedAt() { throw new UnsupportedOperationException(); }
    @Override
    public String getDashboardUrl() { throw new UnsupportedOperationException(); }
    @Override
    public LastOperation getLastOperation() { throw new UnsupportedOperationException(); }
    @Override
    public MaintenanceInfo getMaintenanceInfo() { throw new UnsupportedOperationException(); }
    @Override
    public Metadata getMetadata() { throw new UnsupportedOperationException(); }
    @Override
    public String getName() { throw new UnsupportedOperationException(); }
    @Override
    public ServiceInstanceRelationships getRelationships() { throw new UnsupportedOperationException(); }
    @Override
    public String getRouteServiceUrl() { throw new UnsupportedOperationException(); }
    @Override
    public String getSyslogDrainUrl() { throw new UnsupportedOperationException(); }
    @Override
    public List getTags() { throw new UnsupportedOperationException(); }
    @Override
    public ServiceInstanceType getType() { throw new UnsupportedOperationException(); }
    @Override
    public Boolean getUpdateAvailable() { 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 ServiceInstanceResource fromJson(Json json) {
    ServiceInstanceResource.Builder builder = ServiceInstanceResource.builder();
    if (json.createdAt != null) {
      builder.createdAt(json.createdAt);
    }
    if (json.id != null) {
      builder.id(json.id);
    }
    if (json.links != null) {
      builder.putAllLinks(json.links);
    }
    if (json.updatedAt != null) {
      builder.updatedAt(json.updatedAt);
    }
    if (json.dashboardUrl != null) {
      builder.dashboardUrl(json.dashboardUrl);
    }
    if (json.lastOperation != null) {
      builder.lastOperation(json.lastOperation);
    }
    if (json.maintenanceInfo != null) {
      builder.maintenanceInfo(json.maintenanceInfo);
    }
    if (json.metadata != null) {
      builder.metadata(json.metadata);
    }
    if (json.name != null) {
      builder.name(json.name);
    }
    if (json.relationships != null) {
      builder.relationships(json.relationships);
    }
    if (json.routeServiceUrl != null) {
      builder.routeServiceUrl(json.routeServiceUrl);
    }
    if (json.syslogDrainUrl != null) {
      builder.syslogDrainUrl(json.syslogDrainUrl);
    }
    if (json.tags != null) {
      builder.addAllTags(json.tags);
    }
    if (json.type != null) {
      builder.type(json.type);
    }
    if (json.updateAvailable != null) {
      builder.updateAvailable(json.updateAvailable);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link ServiceInstanceResource ServiceInstanceResource}.
   * 
   * ServiceInstanceResource.builder()
   *    .createdAt(String) // required {@link ServiceInstanceResource#getCreatedAt() createdAt}
   *    .id(String) // required {@link ServiceInstanceResource#getId() id}
   *    .link|putAllLinks(String => Link) // {@link ServiceInstanceResource#getLinks() links} mappings
   *    .updatedAt(String | null) // nullable {@link ServiceInstanceResource#getUpdatedAt() updatedAt}
   *    .dashboardUrl(String | null) // nullable {@link ServiceInstanceResource#getDashboardUrl() dashboardUrl}
   *    .lastOperation(org.cloudfoundry.client.v3.LastOperation | null) // nullable {@link ServiceInstanceResource#getLastOperation() lastOperation}
   *    .maintenanceInfo(org.cloudfoundry.client.v3.MaintenanceInfo | null) // nullable {@link ServiceInstanceResource#getMaintenanceInfo() maintenanceInfo}
   *    .metadata(org.cloudfoundry.client.v3.Metadata | null) // nullable {@link ServiceInstanceResource#getMetadata() metadata}
   *    .name(String) // required {@link ServiceInstanceResource#getName() name}
   *    .relationships(org.cloudfoundry.client.v3.serviceinstances.ServiceInstanceRelationships | null) // nullable {@link ServiceInstanceResource#getRelationships() relationships}
   *    .routeServiceUrl(String | null) // nullable {@link ServiceInstanceResource#getRouteServiceUrl() routeServiceUrl}
   *    .syslogDrainUrl(String | null) // nullable {@link ServiceInstanceResource#getSyslogDrainUrl() syslogDrainUrl}
   *    .tags(List&lt;String&gt; | null) // nullable {@link ServiceInstanceResource#getTags() tags}
   *    .type(org.cloudfoundry.client.v3.serviceinstances.ServiceInstanceType | null) // nullable {@link ServiceInstanceResource#getType() type}
   *    .updateAvailable(Boolean | null) // nullable {@link ServiceInstanceResource#getUpdateAvailable() updateAvailable}
   *    .build();
   * 
* @return A new ServiceInstanceResource builder */ public static ServiceInstanceResource.Builder builder() { return new ServiceInstanceResource.Builder(); } /** * Builds instances of type {@link ServiceInstanceResource ServiceInstanceResource}. * 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 = "_ServiceInstanceResource", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_CREATED_AT = 0x1L; private static final long INIT_BIT_ID = 0x2L; private static final long INIT_BIT_NAME = 0x4L; private long initBits = 0x7L; private String createdAt; private String id; private Map links = new LinkedHashMap(); private String updatedAt; private String dashboardUrl; private LastOperation lastOperation; private MaintenanceInfo maintenanceInfo; private Metadata metadata; private String name; private ServiceInstanceRelationships relationships; private String routeServiceUrl; private String syslogDrainUrl; private List tags = null; private ServiceInstanceType type; private Boolean updateAvailable; private Builder() { } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.v3.serviceinstances.ServiceInstance} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ServiceInstance instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.client.v3.Resource} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(Resource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code ServiceInstanceResource} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ServiceInstanceResource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Copy abstract value type {@code _ServiceInstanceResource} 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(_ServiceInstanceResource instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } private void from(short _unused, Object object) { long bits = 0; if (object instanceof ServiceInstance) { ServiceInstance instance = (ServiceInstance) object; if ((bits & 0x1L) == 0) { String dashboardUrlValue = instance.getDashboardUrl(); if (dashboardUrlValue != null) { dashboardUrl(dashboardUrlValue); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { Metadata metadataValue = instance.getMetadata(); if (metadataValue != null) { metadata(metadataValue); } bits |= 0x2L; } if ((bits & 0x4L) == 0) { ServiceInstanceType typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } bits |= 0x4L; } if ((bits & 0x8L) == 0) { MaintenanceInfo maintenanceInfoValue = instance.getMaintenanceInfo(); if (maintenanceInfoValue != null) { maintenanceInfo(maintenanceInfoValue); } bits |= 0x8L; } if ((bits & 0x10L) == 0) { List tagsValue = instance.getTags(); if (tagsValue != null) { addAllTags(tagsValue); } bits |= 0x10L; } if ((bits & 0x20L) == 0) { createdAt(instance.getCreatedAt()); bits |= 0x20L; } if ((bits & 0x40L) == 0) { ServiceInstanceRelationships relationshipsValue = instance.getRelationships(); if (relationshipsValue != null) { relationships(relationshipsValue); } bits |= 0x40L; } if ((bits & 0x80L) == 0) { LastOperation lastOperationValue = instance.getLastOperation(); if (lastOperationValue != null) { lastOperation(lastOperationValue); } bits |= 0x80L; } if ((bits & 0x100L) == 0) { name(instance.getName()); bits |= 0x100L; } if ((bits & 0x200L) == 0) { putAllLinks(instance.getLinks()); bits |= 0x200L; } if ((bits & 0x400L) == 0) { id(instance.getId()); bits |= 0x400L; } if ((bits & 0x800L) == 0) { String routeServiceUrlValue = instance.getRouteServiceUrl(); if (routeServiceUrlValue != null) { routeServiceUrl(routeServiceUrlValue); } bits |= 0x800L; } if ((bits & 0x1000L) == 0) { Boolean updateAvailableValue = instance.getUpdateAvailable(); if (updateAvailableValue != null) { updateAvailable(updateAvailableValue); } bits |= 0x1000L; } if ((bits & 0x2000L) == 0) { String syslogDrainUrlValue = instance.getSyslogDrainUrl(); if (syslogDrainUrlValue != null) { syslogDrainUrl(syslogDrainUrlValue); } bits |= 0x2000L; } if ((bits & 0x4000L) == 0) { String updatedAtValue = instance.getUpdatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x4000L; } } if (object instanceof Resource) { Resource instance = (Resource) object; if ((bits & 0x20L) == 0) { createdAt(instance.getCreatedAt()); bits |= 0x20L; } if ((bits & 0x200L) == 0) { putAllLinks(instance.getLinks()); bits |= 0x200L; } if ((bits & 0x400L) == 0) { id(instance.getId()); bits |= 0x400L; } if ((bits & 0x4000L) == 0) { String updatedAtValue = instance.getUpdatedAt(); if (updatedAtValue != null) { updatedAt(updatedAtValue); } bits |= 0x4000L; } } if (object instanceof org.cloudfoundry.client.v3.serviceinstances._ServiceInstanceResource) { org.cloudfoundry.client.v3.serviceinstances._ServiceInstanceResource instance = (org.cloudfoundry.client.v3.serviceinstances._ServiceInstanceResource) object; if ((bits & 0x40L) == 0) { ServiceInstanceRelationships relationshipsValue = instance.getRelationships(); if (relationshipsValue != null) { relationships(relationshipsValue); } bits |= 0x40L; } if ((bits & 0x1L) == 0) { String dashboardUrlValue = instance.getDashboardUrl(); if (dashboardUrlValue != null) { dashboardUrl(dashboardUrlValue); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { Metadata metadataValue = instance.getMetadata(); if (metadataValue != null) { metadata(metadataValue); } bits |= 0x2L; } if ((bits & 0x80L) == 0) { LastOperation lastOperationValue = instance.getLastOperation(); if (lastOperationValue != null) { lastOperation(lastOperationValue); } bits |= 0x80L; } if ((bits & 0x100L) == 0) { name(instance.getName()); bits |= 0x100L; } if ((bits & 0x4L) == 0) { ServiceInstanceType typeValue = instance.getType(); if (typeValue != null) { type(typeValue); } bits |= 0x4L; } if ((bits & 0x800L) == 0) { String routeServiceUrlValue = instance.getRouteServiceUrl(); if (routeServiceUrlValue != null) { routeServiceUrl(routeServiceUrlValue); } bits |= 0x800L; } if ((bits & 0x1000L) == 0) { Boolean updateAvailableValue = instance.getUpdateAvailable(); if (updateAvailableValue != null) { updateAvailable(updateAvailableValue); } bits |= 0x1000L; } if ((bits & 0x8L) == 0) { MaintenanceInfo maintenanceInfoValue = instance.getMaintenanceInfo(); if (maintenanceInfoValue != null) { maintenanceInfo(maintenanceInfoValue); } bits |= 0x8L; } if ((bits & 0x2000L) == 0) { String syslogDrainUrlValue = instance.getSyslogDrainUrl(); if (syslogDrainUrlValue != null) { syslogDrainUrl(syslogDrainUrlValue); } bits |= 0x2000L; } if ((bits & 0x10L) == 0) { List tagsValue = instance.getTags(); if (tagsValue != null) { addAllTags(tagsValue); } bits |= 0x10L; } } } /** * Initializes the value for the {@link ServiceInstanceResource#getCreatedAt() createdAt} attribute. * @param createdAt The value for createdAt * @return {@code this} builder for use in a chained invocation */ public final Builder createdAt(String createdAt) { this.createdAt = Objects.requireNonNull(createdAt, "createdAt"); initBits &= ~INIT_BIT_CREATED_AT; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Put one entry to the {@link ServiceInstanceResource#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) { this.links.put(key, value); return this; } /** * Put one entry to the {@link ServiceInstanceResource#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) { 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 ServiceInstanceResource#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 links(Map entries) { this.links.clear(); return putAllLinks(entries); } /** * Put all mappings from the specified map as entries to {@link ServiceInstanceResource#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) { for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Link v = e.getValue(); this.links.put(k, v); } return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getUpdatedAt() updatedAt} attribute. * @param updatedAt The value for updatedAt (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder updatedAt(@Nullable String updatedAt) { this.updatedAt = updatedAt; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getDashboardUrl() dashboardUrl} attribute. * @param dashboardUrl The value for dashboardUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder dashboardUrl(@Nullable String dashboardUrl) { this.dashboardUrl = dashboardUrl; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getLastOperation() lastOperation} attribute. * @param lastOperation The value for lastOperation (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder lastOperation(@Nullable LastOperation lastOperation) { this.lastOperation = lastOperation; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getMaintenanceInfo() maintenanceInfo} attribute. * @param maintenanceInfo The value for maintenanceInfo (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder maintenanceInfo(@Nullable MaintenanceInfo maintenanceInfo) { this.maintenanceInfo = maintenanceInfo; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getMetadata() metadata} attribute. * @param metadata The value for metadata (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder metadata(@Nullable Metadata metadata) { this.metadata = metadata; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getName() name} attribute. * @param name The value for name * @return {@code this} builder for use in a chained invocation */ public final Builder name(String name) { this.name = Objects.requireNonNull(name, "name"); initBits &= ~INIT_BIT_NAME; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getRelationships() relationships} attribute. * @param relationships The value for relationships (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder relationships(@Nullable ServiceInstanceRelationships relationships) { this.relationships = relationships; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getRouteServiceUrl() routeServiceUrl} attribute. * @param routeServiceUrl The value for routeServiceUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder routeServiceUrl(@Nullable String routeServiceUrl) { this.routeServiceUrl = routeServiceUrl; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getSyslogDrainUrl() syslogDrainUrl} attribute. * @param syslogDrainUrl The value for syslogDrainUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder syslogDrainUrl(@Nullable String syslogDrainUrl) { this.syslogDrainUrl = syslogDrainUrl; return this; } /** * Adds one element to {@link ServiceInstanceResource#getTags() tags} list. * @param element A tags element * @return {@code this} builder for use in a chained invocation */ public final Builder tag(String element) { if (this.tags == null) { this.tags = new ArrayList(); } this.tags.add(Objects.requireNonNull(element, "tags element")); return this; } /** * Adds elements to {@link ServiceInstanceResource#getTags() tags} list. * @param elements An array of tags elements * @return {@code this} builder for use in a chained invocation */ public final Builder tags(String... elements) { if (this.tags == null) { this.tags = new ArrayList(); } for (String element : elements) { this.tags.add(Objects.requireNonNull(element, "tags element")); } return this; } /** * Sets or replaces all elements for {@link ServiceInstanceResource#getTags() tags} list. * @param elements An iterable of tags elements * @return {@code this} builder for use in a chained invocation */ public final Builder tags(@Nullable Iterable elements) { if (elements == null) { this.tags = null; return this; } this.tags = new ArrayList(); return addAllTags(elements); } /** * Adds elements to {@link ServiceInstanceResource#getTags() tags} list. * @param elements An iterable of tags elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllTags(Iterable elements) { Objects.requireNonNull(elements, "tags element"); if (this.tags == null) { this.tags = new ArrayList(); } for (String element : elements) { this.tags.add(Objects.requireNonNull(element, "tags element")); } return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getType() type} attribute. * @param type The value for type (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder type(@Nullable ServiceInstanceType type) { this.type = type; return this; } /** * Initializes the value for the {@link ServiceInstanceResource#getUpdateAvailable() updateAvailable} attribute. * @param updateAvailable The value for updateAvailable (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ public final Builder updateAvailable(@Nullable Boolean updateAvailable) { this.updateAvailable = updateAvailable; return this; } /** * Builds a new {@link ServiceInstanceResource ServiceInstanceResource}. * @return An immutable instance of ServiceInstanceResource * @throws java.lang.IllegalStateException if any required attributes are missing */ public ServiceInstanceResource build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ServiceInstanceResource(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_CREATED_AT) != 0) attributes.add("createdAt"); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name"); return "Cannot build ServiceInstanceResource, 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); } } } 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