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

io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluentImpl Maven / Gradle / Ivy

There is a newer version: 22.0.0
Show newest version
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.BaseFluent;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.function.Predicate;

/** Generated */
@SuppressWarnings(value = "unchecked")
public class V1LoadBalancerIngressFluentImpl>
    extends BaseFluent implements V1LoadBalancerIngressFluent {
  public V1LoadBalancerIngressFluentImpl() {}

  public V1LoadBalancerIngressFluentImpl(
      io.kubernetes.client.openapi.models.V1LoadBalancerIngress instance) {
    this.withHostname(instance.getHostname());

    this.withIp(instance.getIp());

    this.withPorts(instance.getPorts());
  }

  private String hostname;
  private java.lang.String ip;
  private ArrayList ports;

  public java.lang.String getHostname() {
    return this.hostname;
  }

  public A withHostname(java.lang.String hostname) {
    this.hostname = hostname;
    return (A) this;
  }

  public Boolean hasHostname() {
    return this.hostname != null;
  }

  public java.lang.String getIp() {
    return this.ip;
  }

  public A withIp(java.lang.String ip) {
    this.ip = ip;
    return (A) this;
  }

  public java.lang.Boolean hasIp() {
    return this.ip != null;
  }

  public A addToPorts(Integer index, V1PortStatus item) {
    if (this.ports == null) {
      this.ports =
          new java.util.ArrayList();
    }
    io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
        new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
    _visitables.get("ports").add(index >= 0 ? index : _visitables.get("ports").size(), builder);
    this.ports.add(index >= 0 ? index : ports.size(), builder);
    return (A) this;
  }

  public A setToPorts(
      java.lang.Integer index, io.kubernetes.client.openapi.models.V1PortStatus item) {
    if (this.ports == null) {
      this.ports =
          new java.util.ArrayList();
    }
    io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
        new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
    if (index < 0 || index >= _visitables.get("ports").size()) {
      _visitables.get("ports").add(builder);
    } else {
      _visitables.get("ports").set(index, builder);
    }
    if (index < 0 || index >= ports.size()) {
      ports.add(builder);
    } else {
      ports.set(index, builder);
    }
    return (A) this;
  }

  public A addToPorts(io.kubernetes.client.openapi.models.V1PortStatus... items) {
    if (this.ports == null) {
      this.ports =
          new java.util.ArrayList();
    }
    for (io.kubernetes.client.openapi.models.V1PortStatus item : items) {
      io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
          new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
      _visitables.get("ports").add(builder);
      this.ports.add(builder);
    }
    return (A) this;
  }

  public A addAllToPorts(Collection items) {
    if (this.ports == null) {
      this.ports =
          new java.util.ArrayList();
    }
    for (io.kubernetes.client.openapi.models.V1PortStatus item : items) {
      io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
          new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
      _visitables.get("ports").add(builder);
      this.ports.add(builder);
    }
    return (A) this;
  }

  public A removeFromPorts(io.kubernetes.client.openapi.models.V1PortStatus... items) {
    for (io.kubernetes.client.openapi.models.V1PortStatus item : items) {
      io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
          new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
      _visitables.get("ports").remove(builder);
      if (this.ports != null) {
        this.ports.remove(builder);
      }
    }
    return (A) this;
  }

  public A removeAllFromPorts(
      java.util.Collection items) {
    for (io.kubernetes.client.openapi.models.V1PortStatus item : items) {
      io.kubernetes.client.openapi.models.V1PortStatusBuilder builder =
          new io.kubernetes.client.openapi.models.V1PortStatusBuilder(item);
      _visitables.get("ports").remove(builder);
      if (this.ports != null) {
        this.ports.remove(builder);
      }
    }
    return (A) this;
  }

  public A removeMatchingFromPorts(
      Predicate predicate) {
    if (ports == null) return (A) this;
    final Iterator each = ports.iterator();
    final List visitables = _visitables.get("ports");
    while (each.hasNext()) {
      io.kubernetes.client.openapi.models.V1PortStatusBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A) this;
  }

  /**
   * This method has been deprecated, please use method buildPorts instead.
   *
   * @return The buildable object.
   */
  @Deprecated
  public List getPorts() {
    return ports != null ? build(ports) : null;
  }

  public java.util.List buildPorts() {
    return ports != null ? build(ports) : null;
  }

  public io.kubernetes.client.openapi.models.V1PortStatus buildPort(java.lang.Integer index) {
    return this.ports.get(index).build();
  }

  public io.kubernetes.client.openapi.models.V1PortStatus buildFirstPort() {
    return this.ports.get(0).build();
  }

  public io.kubernetes.client.openapi.models.V1PortStatus buildLastPort() {
    return this.ports.get(ports.size() - 1).build();
  }

  public io.kubernetes.client.openapi.models.V1PortStatus buildMatchingPort(
      java.util.function.Predicate
          predicate) {
    for (io.kubernetes.client.openapi.models.V1PortStatusBuilder item : ports) {
      if (predicate.test(item)) {
        return item.build();
      }
    }
    return null;
  }

  public java.lang.Boolean hasMatchingPort(
      java.util.function.Predicate
          predicate) {
    for (io.kubernetes.client.openapi.models.V1PortStatusBuilder item : ports) {
      if (predicate.test(item)) {
        return true;
      }
    }
    return false;
  }

  public A withPorts(java.util.List ports) {
    if (this.ports != null) {
      _visitables.get("ports").removeAll(this.ports);
    }
    if (ports != null) {
      this.ports = new java.util.ArrayList();
      for (io.kubernetes.client.openapi.models.V1PortStatus item : ports) {
        this.addToPorts(item);
      }
    } else {
      this.ports = null;
    }
    return (A) this;
  }

  public A withPorts(io.kubernetes.client.openapi.models.V1PortStatus... ports) {
    if (this.ports != null) {
      this.ports.clear();
    }
    if (ports != null) {
      for (io.kubernetes.client.openapi.models.V1PortStatus item : ports) {
        this.addToPorts(item);
      }
    }
    return (A) this;
  }

  public java.lang.Boolean hasPorts() {
    return ports != null && !ports.isEmpty();
  }

  public V1LoadBalancerIngressFluent.PortsNested addNewPort() {
    return new V1LoadBalancerIngressFluentImpl.PortsNestedImpl();
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested
      addNewPortLike(io.kubernetes.client.openapi.models.V1PortStatus item) {
    return new V1LoadBalancerIngressFluentImpl.PortsNestedImpl(-1, item);
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested
      setNewPortLike(
          java.lang.Integer index, io.kubernetes.client.openapi.models.V1PortStatus item) {
    return new io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluentImpl.PortsNestedImpl(
        index, item);
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested editPort(
      java.lang.Integer index) {
    if (ports.size() <= index) throw new RuntimeException("Can't edit ports. Index exceeds size.");
    return setNewPortLike(index, buildPort(index));
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested
      editFirstPort() {
    if (ports.size() == 0) throw new RuntimeException("Can't edit first ports. The list is empty.");
    return setNewPortLike(0, buildPort(0));
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested
      editLastPort() {
    int index = ports.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last ports. The list is empty.");
    return setNewPortLike(index, buildPort(index));
  }

  public io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested
      editMatchingPort(
          java.util.function.Predicate
              predicate) {
    int index = -1;
    for (int i = 0; i < ports.size(); i++) {
      if (predicate.test(ports.get(i))) {
        index = i;
        break;
      }
    }
    if (index < 0) throw new RuntimeException("Can't edit matching ports. No match found.");
    return setNewPortLike(index, buildPort(index));
  }

  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    V1LoadBalancerIngressFluentImpl that = (V1LoadBalancerIngressFluentImpl) o;
    if (hostname != null ? !hostname.equals(that.hostname) : that.hostname != null) return false;
    if (ip != null ? !ip.equals(that.ip) : that.ip != null) return false;
    if (ports != null ? !ports.equals(that.ports) : that.ports != null) return false;
    return true;
  }

  public int hashCode() {
    return java.util.Objects.hash(hostname, ip, ports, super.hashCode());
  }

  public java.lang.String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (hostname != null) {
      sb.append("hostname:");
      sb.append(hostname + ",");
    }
    if (ip != null) {
      sb.append("ip:");
      sb.append(ip + ",");
    }
    if (ports != null && !ports.isEmpty()) {
      sb.append("ports:");
      sb.append(ports);
    }
    sb.append("}");
    return sb.toString();
  }

  class PortsNestedImpl
      extends V1PortStatusFluentImpl>
      implements io.kubernetes.client.openapi.models.V1LoadBalancerIngressFluent.PortsNested,
          Nested {
    PortsNestedImpl(
        java.lang.Integer index, io.kubernetes.client.openapi.models.V1PortStatus item) {
      this.index = index;
      this.builder = new V1PortStatusBuilder(this, item);
    }

    PortsNestedImpl() {
      this.index = -1;
      this.builder = new io.kubernetes.client.openapi.models.V1PortStatusBuilder(this);
    }

    io.kubernetes.client.openapi.models.V1PortStatusBuilder builder;
    java.lang.Integer index;

    public N and() {
      return (N) V1LoadBalancerIngressFluentImpl.this.setToPorts(index, builder.build());
    }

    public N endPort() {
      return and();
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy