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

annotations.io.alauda.kubernetes.api.model.extensions.NetworkPolicyIngressRuleFluentImpl Maven / Gradle / Ivy

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

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;

public class NetworkPolicyIngressRuleFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements NetworkPolicyIngressRuleFluent{

    private List from =  new ArrayList();
    private List ports =  new ArrayList();

    public NetworkPolicyIngressRuleFluentImpl(){
    }
    public NetworkPolicyIngressRuleFluentImpl(NetworkPolicyIngressRule instance){
            this.withFrom(instance.getFrom()); 
            this.withPorts(instance.getPorts()); 
    }

    public A addToFrom(int index,NetworkPolicyPeer item){
            NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.from.add(index >= 0 ? index : from.size(), builder); return (A)this;
    }

    public A setToFrom(int index,NetworkPolicyPeer item){
            NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= from.size()) { from.add(builder); } else { from.set(index, builder);}
             return (A)this;
    }

    public A addToFrom(NetworkPolicyPeer... items){
            for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.add(builder);this.from.add(builder);} return (A)this;
    }

    public A addAllToFrom(Collection items){
            for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.add(builder);this.from.add(builder);} return (A)this;
    }

    public A removeFromFrom(NetworkPolicyPeer... items){
            for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.remove(builder);this.from.remove(builder);} return (A)this;
    }

    public A removeAllFromFrom(Collection items){
            for (NetworkPolicyPeer item : items) {NetworkPolicyPeerBuilder builder = new NetworkPolicyPeerBuilder(item);_visitables.remove(builder);this.from.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildFrom instead.
 */
@Deprecated public List getFrom(){
            return build(from);
    }

    public List buildFrom(){
            return build(from);
    }

    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(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (NetworkPolicyPeerBuilder item: from) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withFrom(List from){
            _visitables.removeAll(this.from);
            this.from.clear();
            if (from != null) {for (NetworkPolicyPeer item : from){this.addToFrom(item);}} return (A) this;
    }

    public A withFrom(NetworkPolicyPeer... from){
            this.from.clear(); if (from != null) {for (NetworkPolicyPeer item :from){ this.addToFrom(item);}} return (A) this;
    }

    public Boolean hasFrom(){
            return from!= null && !from.isEmpty();
    }

    public NetworkPolicyIngressRuleFluent.FromNested addNewFrom(){
            return new FromNestedImpl();
    }

    public NetworkPolicyIngressRuleFluent.FromNested addNewFromLike(NetworkPolicyPeer item){
            return new FromNestedImpl(-1, item);
    }

    public NetworkPolicyIngressRuleFluent.FromNested setNewFromLike(int index,NetworkPolicyPeer item){
            return new FromNestedImpl(index, item);
    }

    public NetworkPolicyIngressRuleFluent.FromNested editFrom(int index){
            if (from.size() <= index) throw new RuntimeException("Can't edit from. Index exceeds size.");
            return setNewFromLike(index, buildFrom(index));
    }

    public NetworkPolicyIngressRuleFluent.FromNested editFirstFrom(){
            if (from.size() == 0) throw new RuntimeException("Can't edit first from. The list is empty.");
            return setNewFromLike(0, buildFrom(0));
    }

    public NetworkPolicyIngressRuleFluent.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 NetworkPolicyIngressRuleFluent.FromNested editMatchingFrom(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i= 0 ? index : _visitables.size(), builder);this.ports.add(index >= 0 ? index : ports.size(), builder); return (A)this;
    }

    public A setToPorts(int index,NetworkPolicyPort item){
            NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= ports.size()) { ports.add(builder); } else { ports.set(index, builder);}
             return (A)this;
    }

    public A addToPorts(NetworkPolicyPort... items){
            for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.add(builder);this.ports.add(builder);} return (A)this;
    }

    public A addAllToPorts(Collection items){
            for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.add(builder);this.ports.add(builder);} return (A)this;
    }

    public A removeFromPorts(NetworkPolicyPort... items){
            for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.remove(builder);this.ports.remove(builder);} return (A)this;
    }

    public A removeAllFromPorts(Collection items){
            for (NetworkPolicyPort item : items) {NetworkPolicyPortBuilder builder = new NetworkPolicyPortBuilder(item);_visitables.remove(builder);this.ports.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildPorts instead.
 */
@Deprecated public List getPorts(){
            return build(ports);
    }

    public List buildPorts(){
            return build(ports);
    }

    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(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (NetworkPolicyPortBuilder item: ports) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withPorts(List ports){
            _visitables.removeAll(this.ports);
            this.ports.clear();
            if (ports != null) {for (NetworkPolicyPort item : ports){this.addToPorts(item);}} return (A) this;
    }

    public A withPorts(NetworkPolicyPort... ports){
            this.ports.clear(); if (ports != null) {for (NetworkPolicyPort item :ports){ this.addToPorts(item);}} return (A) this;
    }

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

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

    public NetworkPolicyIngressRuleFluent.PortsNested addNewPortLike(NetworkPolicyPort item){
            return new PortsNestedImpl(-1, item);
    }

    public NetworkPolicyIngressRuleFluent.PortsNested setNewPortLike(int index,NetworkPolicyPort item){
            return new PortsNestedImpl(index, item);
    }

    public NetworkPolicyIngressRuleFluent.PortsNested editPort(int index){
            if (ports.size() <= index) throw new RuntimeException("Can't edit ports. Index exceeds size.");
            return setNewPortLike(index, buildPort(index));
    }

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

    public NetworkPolicyIngressRuleFluent.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 NetworkPolicyIngressRuleFluent.PortsNested editMatchingPort(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends NetworkPolicyPeerFluentImpl> implements NetworkPolicyIngressRuleFluent.FromNested,io.alauda.kubernetes.api.builder.Nested{

            private final NetworkPolicyPeerBuilder builder;
        private final int index;
    
            FromNestedImpl(int index,NetworkPolicyPeer item){
                    this.index = index;
                    this.builder = new NetworkPolicyPeerBuilder(this, item);
            }
            FromNestedImpl(){
                    this.index = -1;
                    this.builder = new NetworkPolicyPeerBuilder(this);
            }
    
    public N and(){
            return (N) NetworkPolicyIngressRuleFluentImpl.this.setToFrom(index, builder.build());
    }
    public N endFrom(){
            return and();
    }

}
    public class PortsNestedImpl extends NetworkPolicyPortFluentImpl> implements NetworkPolicyIngressRuleFluent.PortsNested,io.alauda.kubernetes.api.builder.Nested{

            private final NetworkPolicyPortBuilder builder;
        private final int index;
    
            PortsNestedImpl(int index,NetworkPolicyPort item){
                    this.index = index;
                    this.builder = new NetworkPolicyPortBuilder(this, item);
            }
            PortsNestedImpl(){
                    this.index = -1;
                    this.builder = new NetworkPolicyPortBuilder(this);
            }
    
    public N and(){
            return (N) NetworkPolicyIngressRuleFluentImpl.this.setToPorts(index, builder.build());
    }
    public N endPort(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy