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

org.cloudfoundry.reactor.RootPayloadRootProvider Maven / Gradle / Ivy

The newest version!
package org.cloudfoundry.reactor;

import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.immutables.value.Generated;

/**
 * A {@link RootProvider} that returns endpoints extracted from the `/` API for the configured endpoint.
 */
@Generated(from = "_RootPayloadRootProvider", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class RootPayloadRootProvider extends org.cloudfoundry.reactor._RootPayloadRootProvider {
  private final String apiHost;
  private final Integer port;
  private final Boolean secure;
  private final ObjectMapper objectMapper;

  private RootPayloadRootProvider(RootPayloadRootProvider.Builder builder) {
    this.apiHost = builder.apiHost;
    this.port = builder.port;
    this.secure = builder.secure;
    this.objectMapper = builder.objectMapper;
  }

  /**
   * The hostname of the API root. Typically something like {@code api.run.pivotal.io}.
   */
  @Override
  public String getApiHost() {
    return apiHost;
  }

  /**
   * The port for the Cloud Foundry instance. Defaults to {@code 443}.
   */
  @Override
  public Optional getPort() {
    return Optional.ofNullable(port);
  }

  /**
   * Whether the connection to the root API should be secure (i.e. using HTTPS). Defaults to {@code true}.
   */
  @Override
  public Optional getSecure() {
    return Optional.ofNullable(secure);
  }

  /**
   * @return The value of the {@code objectMapper} attribute
   */
  @Override
  public ObjectMapper getObjectMapper() {
    return objectMapper;
  }

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

  private boolean equalTo(int synthetic, RootPayloadRootProvider another) {
    return apiHost.equals(another.apiHost)
        && Objects.equals(port, another.port)
        && Objects.equals(secure, another.secure)
        && objectMapper.equals(another.objectMapper);
  }

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

  /**
   * Prints the immutable value {@code RootPayloadRootProvider} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    StringBuilder builder = new StringBuilder("RootPayloadRootProvider{");
    builder.append("apiHost=").append(apiHost);
    if (port != null) {
      builder.append(", ");
      builder.append("port=").append(port);
    }
    if (secure != null) {
      builder.append(", ");
      builder.append("secure=").append(secure);
    }
    builder.append(", ");
    builder.append("objectMapper=").append(objectMapper);
    return builder.append("}").toString();
  }

  private static RootPayloadRootProvider validate(RootPayloadRootProvider instance) {
    instance.checkForValidApiHost();
    return instance;
  }

  /**
   * Creates a builder for {@link RootPayloadRootProvider RootPayloadRootProvider}.
   * 
   * RootPayloadRootProvider.builder()
   *    .apiHost(String) // required {@link RootPayloadRootProvider#getApiHost() apiHost}
   *    .port(Integer) // optional {@link RootPayloadRootProvider#getPort() port}
   *    .secure(Boolean) // optional {@link RootPayloadRootProvider#getSecure() secure}
   *    .objectMapper(com.fasterxml.jackson.databind.ObjectMapper) // required {@link RootPayloadRootProvider#getObjectMapper() objectMapper}
   *    .build();
   * 
* @return A new RootPayloadRootProvider builder */ public static RootPayloadRootProvider.Builder builder() { return new RootPayloadRootProvider.Builder(); } /** * Builds instances of type {@link RootPayloadRootProvider RootPayloadRootProvider}. * 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 = "_RootPayloadRootProvider", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_API_HOST = 0x1L; private static final long INIT_BIT_OBJECT_MAPPER = 0x2L; private long initBits = 0x3L; private String apiHost; private Integer port; private Boolean secure; private ObjectMapper objectMapper; private Builder() { } /** * Fill a builder with attribute values from the provided {@code org.cloudfoundry.reactor.AbstractRootProvider} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(AbstractRootProvider instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code RootPayloadRootProvider} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(RootPayloadRootProvider instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Copy abstract value type {@code _RootPayloadRootProvider} 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(_RootPayloadRootProvider 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 AbstractRootProvider) { AbstractRootProvider instance = (AbstractRootProvider) object; if ((bits & 0x2L) == 0) { Optional secureOptional = instance.getSecure(); if (secureOptional.isPresent()) { secure(secureOptional); } bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional portOptional = instance.getPort(); if (portOptional.isPresent()) { port(portOptional); } bits |= 0x4L; } if ((bits & 0x1L) == 0) { apiHost(instance.getApiHost()); bits |= 0x1L; } } if (object instanceof org.cloudfoundry.reactor._RootPayloadRootProvider) { org.cloudfoundry.reactor._RootPayloadRootProvider instance = (org.cloudfoundry.reactor._RootPayloadRootProvider) object; objectMapper(instance.getObjectMapper()); if ((bits & 0x2L) == 0) { Optional secureOptional = instance.getSecure(); if (secureOptional.isPresent()) { secure(secureOptional); } bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional portOptional = instance.getPort(); if (portOptional.isPresent()) { port(portOptional); } bits |= 0x4L; } if ((bits & 0x1L) == 0) { apiHost(instance.getApiHost()); bits |= 0x1L; } } } /** * Initializes the value for the {@link RootPayloadRootProvider#getApiHost() apiHost} attribute. * @param apiHost The value for apiHost * @return {@code this} builder for use in a chained invocation */ public final Builder apiHost(String apiHost) { this.apiHost = Objects.requireNonNull(apiHost, "apiHost"); initBits &= ~INIT_BIT_API_HOST; return this; } /** * Initializes the optional value {@link RootPayloadRootProvider#getPort() port} to port. * @param port The value for port * @return {@code this} builder for chained invocation */ public final Builder port(int port) { this.port = port; return this; } /** * Initializes the optional value {@link RootPayloadRootProvider#getPort() port} to port. * @param port The value for port * @return {@code this} builder for use in a chained invocation */ public final Builder port(Optional port) { this.port = port.orElse(null); return this; } /** * Initializes the optional value {@link RootPayloadRootProvider#getSecure() secure} to secure. * @param secure The value for secure * @return {@code this} builder for chained invocation */ public final Builder secure(boolean secure) { this.secure = secure; return this; } /** * Initializes the optional value {@link RootPayloadRootProvider#getSecure() secure} to secure. * @param secure The value for secure * @return {@code this} builder for use in a chained invocation */ public final Builder secure(Optional secure) { this.secure = secure.orElse(null); return this; } /** * Initializes the value for the {@link RootPayloadRootProvider#getObjectMapper() objectMapper} attribute. * @param objectMapper The value for objectMapper * @return {@code this} builder for use in a chained invocation */ public final Builder objectMapper(ObjectMapper objectMapper) { this.objectMapper = Objects.requireNonNull(objectMapper, "objectMapper"); initBits &= ~INIT_BIT_OBJECT_MAPPER; return this; } /** * Builds a new {@link RootPayloadRootProvider RootPayloadRootProvider}. * @return An immutable instance of RootPayloadRootProvider * @throws java.lang.IllegalStateException if any required attributes are missing */ public RootPayloadRootProvider build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return RootPayloadRootProvider.validate(new RootPayloadRootProvider(this)); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_API_HOST) != 0) attributes.add("apiHost"); if ((initBits & INIT_BIT_OBJECT_MAPPER) != 0) attributes.add("objectMapper"); return "Cannot build RootPayloadRootProvider, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy