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

org.cloudfoundry.client.v2.servicekeys.ServiceKeyEntity Maven / Gradle / Ivy

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

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.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.immutables.value.Generated;

/**
 * The entity response payload for Service Keys
 */
@Generated(from = "_ServiceKeyEntity", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ServiceKeyEntity extends org.cloudfoundry.client.v2.servicekeys._ServiceKeyEntity {
  private final @Nullable Map credentials;
  private final @Nullable String name;
  private final @Nullable String serviceInstanceId;
  private final @Nullable String serviceInstanceUrl;
  private final @Nullable String serviceKeyParametersUrl;

  private ServiceKeyEntity(ServiceKeyEntity.Builder builder) {
    this.credentials = builder.credentials == null ? null : createUnmodifiableMap(false, false, builder.credentials);
    this.name = builder.name;
    this.serviceInstanceId = builder.serviceInstanceId;
    this.serviceInstanceUrl = builder.serviceInstanceUrl;
    this.serviceKeyParametersUrl = builder.serviceKeyParametersUrl;
  }

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

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

  /**
   * The service instance id
   */
  @JsonProperty("service_instance_guid")
  @Override
  public @Nullable String getServiceInstanceId() {
    return serviceInstanceId;
  }

  /**
   * The service instance url
   */
  @JsonProperty("service_instance_url")
  @Override
  public @Nullable String getServiceInstanceUrl() {
    return serviceInstanceUrl;
  }

  /**
   * The service key parameters url
   */
  @JsonProperty("service_key_parameters_url")
  @Override
  public @Nullable String getServiceKeyParametersUrl() {
    return serviceKeyParametersUrl;
  }

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

  private boolean equalTo(int synthetic, ServiceKeyEntity another) {
    return Objects.equals(credentials, another.credentials)
        && Objects.equals(name, another.name)
        && Objects.equals(serviceInstanceId, another.serviceInstanceId)
        && Objects.equals(serviceInstanceUrl, another.serviceInstanceUrl)
        && Objects.equals(serviceKeyParametersUrl, another.serviceKeyParametersUrl);
  }

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

  /**
   * Prints the immutable value {@code ServiceKeyEntity} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "ServiceKeyEntity{"
        + "credentials=" + credentials
        + ", name=" + name
        + ", serviceInstanceId=" + serviceInstanceId
        + ", serviceInstanceUrl=" + serviceInstanceUrl
        + ", serviceKeyParametersUrl=" + serviceKeyParametersUrl
        + "}";
  }

  /**
   * 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 = "_ServiceKeyEntity", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.client.v2.servicekeys._ServiceKeyEntity {
    Map credentials = null;
    String name;
    String serviceInstanceId;
    String serviceInstanceUrl;
    String serviceKeyParametersUrl;
    @JsonProperty("credentials")
    public void setCredentials(@Nullable Map credentials) {
      this.credentials = credentials;
    }
    @JsonProperty("name")
    public void setName(@Nullable String name) {
      this.name = name;
    }
    @JsonProperty("service_instance_guid")
    public void setServiceInstanceId(@Nullable String serviceInstanceId) {
      this.serviceInstanceId = serviceInstanceId;
    }
    @JsonProperty("service_instance_url")
    public void setServiceInstanceUrl(@Nullable String serviceInstanceUrl) {
      this.serviceInstanceUrl = serviceInstanceUrl;
    }
    @JsonProperty("service_key_parameters_url")
    public void setServiceKeyParametersUrl(@Nullable String serviceKeyParametersUrl) {
      this.serviceKeyParametersUrl = serviceKeyParametersUrl;
    }
    @Override
    public Map getCredentials() { throw new UnsupportedOperationException(); }
    @Override
    public String getName() { throw new UnsupportedOperationException(); }
    @Override
    public String getServiceInstanceId() { throw new UnsupportedOperationException(); }
    @Override
    public String getServiceInstanceUrl() { throw new UnsupportedOperationException(); }
    @Override
    public String getServiceKeyParametersUrl() { 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 ServiceKeyEntity fromJson(Json json) {
    ServiceKeyEntity.Builder builder = ServiceKeyEntity.builder();
    if (json.credentials != null) {
      builder.putAllCredentials(json.credentials);
    }
    if (json.name != null) {
      builder.name(json.name);
    }
    if (json.serviceInstanceId != null) {
      builder.serviceInstanceId(json.serviceInstanceId);
    }
    if (json.serviceInstanceUrl != null) {
      builder.serviceInstanceUrl(json.serviceInstanceUrl);
    }
    if (json.serviceKeyParametersUrl != null) {
      builder.serviceKeyParametersUrl(json.serviceKeyParametersUrl);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link ServiceKeyEntity ServiceKeyEntity}.
   * 
   * ServiceKeyEntity.builder()
   *    .credentials(Map&lt;String, Object&gt; | null) // nullable {@link ServiceKeyEntity#getCredentials() credentials}
   *    .name(String | null) // nullable {@link ServiceKeyEntity#getName() name}
   *    .serviceInstanceId(String | null) // nullable {@link ServiceKeyEntity#getServiceInstanceId() serviceInstanceId}
   *    .serviceInstanceUrl(String | null) // nullable {@link ServiceKeyEntity#getServiceInstanceUrl() serviceInstanceUrl}
   *    .serviceKeyParametersUrl(String | null) // nullable {@link ServiceKeyEntity#getServiceKeyParametersUrl() serviceKeyParametersUrl}
   *    .build();
   * 
* @return A new ServiceKeyEntity builder */ public static ServiceKeyEntity.Builder builder() { return new ServiceKeyEntity.Builder(); } /** * Builds instances of type {@link ServiceKeyEntity ServiceKeyEntity}. * 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 = "_ServiceKeyEntity", generator = "Immutables") public static final class Builder { private Map credentials = null; private String name; private String serviceInstanceId; private String serviceInstanceUrl; private String serviceKeyParametersUrl; private Builder() { } /** * Fill a builder with attribute values from the provided {@code ServiceKeyEntity} 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(ServiceKeyEntity instance) { return from((_ServiceKeyEntity) instance); } /** * Copy abstract value type {@code _ServiceKeyEntity} 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(_ServiceKeyEntity instance) { Objects.requireNonNull(instance, "instance"); Map credentialsValue = instance.getCredentials(); if (credentialsValue != null) { putAllCredentials(credentialsValue); } String nameValue = instance.getName(); if (nameValue != null) { name(nameValue); } String serviceInstanceIdValue = instance.getServiceInstanceId(); if (serviceInstanceIdValue != null) { serviceInstanceId(serviceInstanceIdValue); } String serviceInstanceUrlValue = instance.getServiceInstanceUrl(); if (serviceInstanceUrlValue != null) { serviceInstanceUrl(serviceInstanceUrlValue); } String serviceKeyParametersUrlValue = instance.getServiceKeyParametersUrl(); if (serviceKeyParametersUrlValue != null) { serviceKeyParametersUrl(serviceKeyParametersUrlValue); } return this; } /** * Put one entry to the {@link ServiceKeyEntity#getCredentials() credentials} map. * @param key The key in the credentials map * @param value The associated value in the credentials map * @return {@code this} builder for use in a chained invocation */ public final Builder credential(String key, Object value) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } this.credentials.put(key, value); return this; } /** * Put one entry to the {@link ServiceKeyEntity#getCredentials() credentials} 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 credential(Map.Entry entry) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } String k = entry.getKey(); Object v = entry.getValue(); this.credentials.put(k, v); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link ServiceKeyEntity#getCredentials() credentials} 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 credentials map * @return {@code this} builder for use in a chained invocation */ @JsonProperty("credentials") public final Builder credentials(@Nullable Map entries) { if (entries == null) { this.credentials = null; return this; } this.credentials = new LinkedHashMap(); return putAllCredentials(entries); } /** * Put all mappings from the specified map as entries to {@link ServiceKeyEntity#getCredentials() credentials} map. Nulls are not permitted * @param entries The entries that will be added to the credentials map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllCredentials(Map entries) { if (this.credentials == null) { this.credentials = new LinkedHashMap(); } for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); Object v = e.getValue(); this.credentials.put(k, v); } return this; } /** * Initializes the value for the {@link ServiceKeyEntity#getName() name} attribute. * @param name The value for name (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("name") public final Builder name(@Nullable String name) { this.name = name; return this; } /** * Initializes the value for the {@link ServiceKeyEntity#getServiceInstanceId() serviceInstanceId} attribute. * @param serviceInstanceId The value for serviceInstanceId (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("service_instance_guid") public final Builder serviceInstanceId(@Nullable String serviceInstanceId) { this.serviceInstanceId = serviceInstanceId; return this; } /** * Initializes the value for the {@link ServiceKeyEntity#getServiceInstanceUrl() serviceInstanceUrl} attribute. * @param serviceInstanceUrl The value for serviceInstanceUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("service_instance_url") public final Builder serviceInstanceUrl(@Nullable String serviceInstanceUrl) { this.serviceInstanceUrl = serviceInstanceUrl; return this; } /** * Initializes the value for the {@link ServiceKeyEntity#getServiceKeyParametersUrl() serviceKeyParametersUrl} attribute. * @param serviceKeyParametersUrl The value for serviceKeyParametersUrl (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("service_key_parameters_url") public final Builder serviceKeyParametersUrl(@Nullable String serviceKeyParametersUrl) { this.serviceKeyParametersUrl = serviceKeyParametersUrl; return this; } /** * Builds a new {@link ServiceKeyEntity ServiceKeyEntity}. * @return An immutable instance of ServiceKeyEntity * @throws java.lang.IllegalStateException if any required attributes are missing */ public ServiceKeyEntity build() { return new ServiceKeyEntity(this); } } 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