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

io.fabric8.kubernetes.api.model.extensions.NetworkPolicyIngressRuleFluent Maven / Gradle / Ivy

There is a newer version: 6.13.4
Show newest version
package io.fabric8.kubernetes.api.model.extensions;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;

/**
 * Generated
 */
@SuppressWarnings("unchecked")
public class NetworkPolicyIngressRuleFluent> extends BaseFluent{
  public NetworkPolicyIngressRuleFluent() {
  }
  
  public NetworkPolicyIngressRuleFluent(NetworkPolicyIngressRule instance) {
    this.copyInstance(instance);
  }
  private ArrayList from = new ArrayList();
  private ArrayList ports = new ArrayList();
  private Map additionalProperties;
  
  protected void copyInstance(NetworkPolicyIngressRule instance) {
    instance = (instance != null ? instance : new NetworkPolicyIngressRule());
    if (instance != null) {
          this.withFrom(instance.getFrom());
          this.withPorts(instance.getPorts());
          this.withAdditionalProperties(instance.getAdditionalProperties());
        }
  }
  
  public A addToFrom(int index,NetworkPolicyPeer item) {
    if (this.from == null) {this.from = new ArrayList();}
    NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);
    if (index < 0 || index >= from.size()) { _visitables.get("from").add(builder); from.add(builder); } else { _visitables.get("from").add(index, builder); from.add(index, builder);}
    return (A)this;
  }
  
  public A setToFrom(int index,NetworkPolicyPeer item) {
    if (this.from == null) {this.from = new ArrayList();}
    NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);
    if (index < 0 || index >= from.size()) { _visitables.get("from").add(builder); from.add(builder); } else { _visitables.get("from").set(index, builder); from.set(index, builder);}
    return (A)this;
  }
  
  public A addToFrom(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPeer... items) {
    if (this.from == null) {this.from = new ArrayList();}
    for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.get("from").add(builder);this.from.add(builder);} return (A)this;
  }
  
  public A addAllToFrom(Collection items) {
    if (this.from == null) {this.from = new ArrayList();}
    for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.get("from").add(builder);this.from.add(builder);} return (A)this;
  }
  
  public A removeFromFrom(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPeer... items) {
    if (this.from == null) return (A)this;
    for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.get("from").remove(builder); this.from.remove(builder);} return (A)this;
  }
  
  public A removeAllFromFrom(Collection items) {
    if (this.from == null) return (A)this;
    for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.get("from").remove(builder); this.from.remove(builder);} return (A)this;
  }
  
  public A removeMatchingFromFrom(Predicate predicate) {
    if (from == null) return (A) this;
    final Iterator each = from.iterator();
    final List visitables = _visitables.get("from");
    while (each.hasNext()) {
      NetworkPolicyPeerBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildFrom() {
    return this.from != null ? build(from) : null;
  }
  
  public NetworkPolicyPeer buildFrom(int index) {
    return this.from.get(index).build();
  }
  
  public NetworkPolicyPeer buildFirstFrom() {
    return this.from.get(0).build();
  }
  
  public NetworkPolicyPeer buildLastFrom() {
    return this.from.get(from.size() - 1).build();
  }
  
  public NetworkPolicyPeer buildMatchingFrom(Predicate predicate) {
      for (NetworkPolicyPeerBuilder item : from) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingFrom(Predicate predicate) {
      for (NetworkPolicyPeerBuilder item : from) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withFrom(List from) {
    if (this.from != null) {
      this._visitables.get("from").clear();
    }
    if (from != null) {
        this.from = new ArrayList();
        for (NetworkPolicyPeer item : from) {
          this.addToFrom(item);
        }
    } else {
      this.from = null;
    }
    return (A) this;
  }
  
  public A withFrom(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPeer... from) {
    if (this.from != null) {
        this.from.clear();
        _visitables.remove("from");
    }
    if (from != null) {
      for (NetworkPolicyPeer item : from) {
        this.addToFrom(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasFrom() {
    return this.from != null && !this.from.isEmpty();
  }
  
  public FromNested addNewFrom() {
    return new FromNested(-1, null);
  }
  
  public FromNested addNewFromLike(NetworkPolicyPeer item) {
    return new FromNested(-1, item);
  }
  
  public FromNested setNewFromLike(int index,NetworkPolicyPeer item) {
    return new FromNested(index, item);
  }
  
  public FromNested editFrom(int index) {
    if (from.size() <= index) throw new RuntimeException("Can't edit from. Index exceeds size.");
    return setNewFromLike(index, buildFrom(index));
  }
  
  public FromNested editFirstFrom() {
    if (from.size() == 0) throw new RuntimeException("Can't edit first from. The list is empty.");
    return setNewFromLike(0, buildFrom(0));
  }
  
  public FromNested editLastFrom() {
    int index = from.size() - 1;
    if (index < 0) throw new RuntimeException("Can't edit last from. The list is empty.");
    return setNewFromLike(index, buildFrom(index));
  }
  
  public FromNested editMatchingFrom(Predicate predicate) {
    int index = -1;
    for (int i=0;i();}
    NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);
    if (index < 0 || index >= ports.size()) { _visitables.get("ports").add(builder); ports.add(builder); } else { _visitables.get("ports").add(index, builder); ports.add(index, builder);}
    return (A)this;
  }
  
  public A setToPorts(int index,NetworkPolicyPort item) {
    if (this.ports == null) {this.ports = new ArrayList();}
    NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);
    if (index < 0 || index >= ports.size()) { _visitables.get("ports").add(builder); ports.add(builder); } else { _visitables.get("ports").set(index, builder); ports.set(index, builder);}
    return (A)this;
  }
  
  public A addToPorts(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPort... items) {
    if (this.ports == null) {this.ports = new ArrayList();}
    for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(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 ArrayList();}
    for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.get("ports").add(builder);this.ports.add(builder);} return (A)this;
  }
  
  public A removeFromPorts(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPort... items) {
    if (this.ports == null) return (A)this;
    for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.get("ports").remove(builder); this.ports.remove(builder);} return (A)this;
  }
  
  public A removeAllFromPorts(Collection items) {
    if (this.ports == null) return (A)this;
    for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.get("ports").remove(builder); 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()) {
      NetworkPolicyPortBuilder builder = each.next();
      if (predicate.test(builder)) {
        visitables.remove(builder);
        each.remove();
      }
    }
    return (A)this;
  }
  
  public List buildPorts() {
    return this.ports != null ? build(ports) : null;
  }
  
  public NetworkPolicyPort buildPort(int index) {
    return this.ports.get(index).build();
  }
  
  public NetworkPolicyPort buildFirstPort() {
    return this.ports.get(0).build();
  }
  
  public NetworkPolicyPort buildLastPort() {
    return this.ports.get(ports.size() - 1).build();
  }
  
  public NetworkPolicyPort buildMatchingPort(Predicate predicate) {
      for (NetworkPolicyPortBuilder item : ports) {
        if (predicate.test(item)) {
          return item.build();
        }
      }
      return null;
  }
  
  public boolean hasMatchingPort(Predicate predicate) {
      for (NetworkPolicyPortBuilder item : ports) {
        if (predicate.test(item)) {
          return true;
        }
      }
      return false;
  }
  
  public A withPorts(List ports) {
    if (this.ports != null) {
      this._visitables.get("ports").clear();
    }
    if (ports != null) {
        this.ports = new ArrayList();
        for (NetworkPolicyPort item : ports) {
          this.addToPorts(item);
        }
    } else {
      this.ports = null;
    }
    return (A) this;
  }
  
  public A withPorts(io.fabric8.kubernetes.api.model.extensions.NetworkPolicyPort... ports) {
    if (this.ports != null) {
        this.ports.clear();
        _visitables.remove("ports");
    }
    if (ports != null) {
      for (NetworkPolicyPort item : ports) {
        this.addToPorts(item);
      }
    }
    return (A) this;
  }
  
  public boolean hasPorts() {
    return this.ports != null && !this.ports.isEmpty();
  }
  
  public PortsNested addNewPort() {
    return new PortsNested(-1, null);
  }
  
  public PortsNested addNewPortLike(NetworkPolicyPort item) {
    return new PortsNested(-1, item);
  }
  
  public PortsNested setNewPortLike(int index,NetworkPolicyPort item) {
    return new PortsNested(index, item);
  }
  
  public PortsNested editPort(int index) {
    if (ports.size() <= index) throw new RuntimeException("Can't edit ports. Index exceeds size.");
    return setNewPortLike(index, buildPort(index));
  }
  
  public PortsNested editFirstPort() {
    if (ports.size() == 0) throw new RuntimeException("Can't edit first ports. The list is empty.");
    return setNewPortLike(0, buildPort(0));
  }
  
  public 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 PortsNested editMatchingPort(Predicate predicate) {
    int index = -1;
    for (int i=0;i map) {
    if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
    if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(String key) {
    if(this.additionalProperties == null) { return (A) this; }
    if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
  }
  
  public A removeFromAdditionalProperties(Map map) {
    if(this.additionalProperties == null) { return (A) this; }
    if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
  }
  
  public Map getAdditionalProperties() {
    return this.additionalProperties;
  }
  
  public A withAdditionalProperties(Map additionalProperties) {
    if (additionalProperties == null) {
      this.additionalProperties = null;
    } else {
      this.additionalProperties = new LinkedHashMap(additionalProperties);
    }
    return (A) this;
  }
  
  public boolean hasAdditionalProperties() {
    return this.additionalProperties != null;
  }
  
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    if (!super.equals(o)) return false;
    NetworkPolicyIngressRuleFluent that = (NetworkPolicyIngressRuleFluent) o;
    if (!java.util.Objects.equals(from, that.from)) return false;
    if (!java.util.Objects.equals(ports, that.ports)) return false;
    if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
    return true;
  }
  
  public int hashCode() {
    return java.util.Objects.hash(from,  ports,  additionalProperties,  super.hashCode());
  }
  
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("{");
    if (from != null && !from.isEmpty()) { sb.append("from:"); sb.append(from + ","); }
    if (ports != null && !ports.isEmpty()) { sb.append("ports:"); sb.append(ports + ","); }
    if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
    sb.append("}");
    return sb.toString();
  }
  public class FromNested extends NetworkPolicyPeerFluent> implements Nested{
    FromNested(int index,NetworkPolicyPeer item) {
      this.index = index;
      this.builder = new NetworkPolicyPeerBuilder(this, item);
    }
    NetworkPolicyPeerBuilder builder;
    int index;
    
    public N and() {
      return (N) NetworkPolicyIngressRuleFluent.this.setToFrom(index,builder.build());
    }
    
    public N endFrom() {
      return and();
    }
    
  
  }
  public class PortsNested extends NetworkPolicyPortFluent> implements Nested{
    PortsNested(int index,NetworkPolicyPort item) {
      this.index = index;
      this.builder = new NetworkPolicyPortBuilder(this, item);
    }
    NetworkPolicyPortBuilder builder;
    int index;
    
    public N and() {
      return (N) NetworkPolicyIngressRuleFluent.this.setToPorts(index,builder.build());
    }
    
    public N endPort() {
      return and();
    }
    
  
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy