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

org.cloudfoundry.client.v3.processes.PortMapping Maven / Gradle / Ivy

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

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

/**
 * A mapping of internal to external ports
 */
@Generated(from = "_PortMapping", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class PortMapping extends org.cloudfoundry.client.v3.processes._PortMapping {
  private final Integer external;
  private final @Nullable Integer externalTlsProxyPort;
  private final Integer internal;
  private final @Nullable Integer internalTlsProxyPort;

  private PortMapping(PortMapping.Builder builder) {
    this.external = builder.external;
    this.externalTlsProxyPort = builder.externalTlsProxyPort;
    this.internal = builder.internal;
    this.internalTlsProxyPort = builder.internalTlsProxyPort;
  }

  /**
   * The external port
   */
  @JsonProperty("external")
  @Override
  public Integer getExternal() {
    return external;
  }

  /**
   * The external TLS proxy port
   */
  @JsonProperty("external_tls_proxy_port")
  @Override
  public @Nullable Integer getExternalTlsProxyPort() {
    return externalTlsProxyPort;
  }

  /**
   * The internal port
   */
  @JsonProperty("internal")
  @Override
  public Integer getInternal() {
    return internal;
  }

  /**
   * The internal TLS proxy port
   */
  @JsonProperty("internal_tls_proxy_port")
  @Override
  public @Nullable Integer getInternalTlsProxyPort() {
    return internalTlsProxyPort;
  }

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

  private boolean equalTo(int synthetic, PortMapping another) {
    return external.equals(another.external)
        && Objects.equals(externalTlsProxyPort, another.externalTlsProxyPort)
        && internal.equals(another.internal)
        && Objects.equals(internalTlsProxyPort, another.internalTlsProxyPort);
  }

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

  /**
   * Prints the immutable value {@code PortMapping} with attribute values.
   * @return A string representation of the value
   */
  @Override
  public String toString() {
    return "PortMapping{"
        + "external=" + external
        + ", externalTlsProxyPort=" + externalTlsProxyPort
        + ", internal=" + internal
        + ", internalTlsProxyPort=" + internalTlsProxyPort
        + "}";
  }

  /**
   * 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 = "_PortMapping", generator = "Immutables")
  @Deprecated
  @JsonDeserialize
  @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
  static final class Json extends org.cloudfoundry.client.v3.processes._PortMapping {
    Integer external;
    Integer externalTlsProxyPort;
    Integer internal;
    Integer internalTlsProxyPort;
    @JsonProperty("external")
    public void setExternal(Integer external) {
      this.external = external;
    }
    @JsonProperty("external_tls_proxy_port")
    public void setExternalTlsProxyPort(@Nullable Integer externalTlsProxyPort) {
      this.externalTlsProxyPort = externalTlsProxyPort;
    }
    @JsonProperty("internal")
    public void setInternal(Integer internal) {
      this.internal = internal;
    }
    @JsonProperty("internal_tls_proxy_port")
    public void setInternalTlsProxyPort(@Nullable Integer internalTlsProxyPort) {
      this.internalTlsProxyPort = internalTlsProxyPort;
    }
    @Override
    public Integer getExternal() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getExternalTlsProxyPort() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getInternal() { throw new UnsupportedOperationException(); }
    @Override
    public Integer getInternalTlsProxyPort() { 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 PortMapping fromJson(Json json) {
    PortMapping.Builder builder = PortMapping.builder();
    if (json.external != null) {
      builder.external(json.external);
    }
    if (json.externalTlsProxyPort != null) {
      builder.externalTlsProxyPort(json.externalTlsProxyPort);
    }
    if (json.internal != null) {
      builder.internal(json.internal);
    }
    if (json.internalTlsProxyPort != null) {
      builder.internalTlsProxyPort(json.internalTlsProxyPort);
    }
    return builder.build();
  }

  /**
   * Creates a builder for {@link PortMapping PortMapping}.
   * 
   * PortMapping.builder()
   *    .external(Integer) // required {@link PortMapping#getExternal() external}
   *    .externalTlsProxyPort(Integer | null) // nullable {@link PortMapping#getExternalTlsProxyPort() externalTlsProxyPort}
   *    .internal(Integer) // required {@link PortMapping#getInternal() internal}
   *    .internalTlsProxyPort(Integer | null) // nullable {@link PortMapping#getInternalTlsProxyPort() internalTlsProxyPort}
   *    .build();
   * 
* @return A new PortMapping builder */ public static PortMapping.Builder builder() { return new PortMapping.Builder(); } /** * Builds instances of type {@link PortMapping PortMapping}. * 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 = "_PortMapping", generator = "Immutables") public static final class Builder { private static final long INIT_BIT_EXTERNAL = 0x1L; private static final long INIT_BIT_INTERNAL = 0x2L; private long initBits = 0x3L; private Integer external; private Integer externalTlsProxyPort; private Integer internal; private Integer internalTlsProxyPort; private Builder() { } /** * Fill a builder with attribute values from the provided {@code PortMapping} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(PortMapping instance) { return from((_PortMapping) instance); } /** * Copy abstract value type {@code _PortMapping} 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(_PortMapping instance) { Objects.requireNonNull(instance, "instance"); external(instance.getExternal()); Integer externalTlsProxyPortValue = instance.getExternalTlsProxyPort(); if (externalTlsProxyPortValue != null) { externalTlsProxyPort(externalTlsProxyPortValue); } internal(instance.getInternal()); Integer internalTlsProxyPortValue = instance.getInternalTlsProxyPort(); if (internalTlsProxyPortValue != null) { internalTlsProxyPort(internalTlsProxyPortValue); } return this; } /** * Initializes the value for the {@link PortMapping#getExternal() external} attribute. * @param external The value for external * @return {@code this} builder for use in a chained invocation */ @JsonProperty("external") public final Builder external(Integer external) { this.external = Objects.requireNonNull(external, "external"); initBits &= ~INIT_BIT_EXTERNAL; return this; } /** * Initializes the value for the {@link PortMapping#getExternalTlsProxyPort() externalTlsProxyPort} attribute. * @param externalTlsProxyPort The value for externalTlsProxyPort (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("external_tls_proxy_port") public final Builder externalTlsProxyPort(@Nullable Integer externalTlsProxyPort) { this.externalTlsProxyPort = externalTlsProxyPort; return this; } /** * Initializes the value for the {@link PortMapping#getInternal() internal} attribute. * @param internal The value for internal * @return {@code this} builder for use in a chained invocation */ @JsonProperty("internal") public final Builder internal(Integer internal) { this.internal = Objects.requireNonNull(internal, "internal"); initBits &= ~INIT_BIT_INTERNAL; return this; } /** * Initializes the value for the {@link PortMapping#getInternalTlsProxyPort() internalTlsProxyPort} attribute. * @param internalTlsProxyPort The value for internalTlsProxyPort (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @JsonProperty("internal_tls_proxy_port") public final Builder internalTlsProxyPort(@Nullable Integer internalTlsProxyPort) { this.internalTlsProxyPort = internalTlsProxyPort; return this; } /** * Builds a new {@link PortMapping PortMapping}. * @return An immutable instance of PortMapping * @throws java.lang.IllegalStateException if any required attributes are missing */ public PortMapping build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new PortMapping(this); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_EXTERNAL) != 0) attributes.add("external"); if ((initBits & INIT_BIT_INTERNAL) != 0) attributes.add("internal"); return "Cannot build PortMapping, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy