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

me.snowdrop.istio.api.model.v1.routing.EgressRuleFluentImpl Maven / Gradle / Ivy

package me.snowdrop.istio.api.model.v1.routing;

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

public class EgressRuleFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements EgressRuleFluent{

    private IstioServiceBuilder destination;
    private List ports;
    private Boolean useEgressProxy;

    public EgressRuleFluentImpl(){
    }
    public EgressRuleFluentImpl(EgressRule instance){
            this.withDestination(instance.getDestination()); 
            this.withPorts(instance.getPorts()); 
            this.withUseEgressProxy(instance.getUseEgressProxy()); 
    }

    
/**
 * This method has been deprecated, please use method buildDestination instead.
 */
@Deprecated public IstioService getDestination(){
            return this.destination!=null?this.destination.build():null;
    }

    public IstioService buildDestination(){
            return this.destination!=null?this.destination.build():null;
    }

    public A withDestination(IstioService destination){
            _visitables.remove(this.destination);
            if (destination!=null){ this.destination= new IstioServiceBuilder(destination); _visitables.add(this.destination);} return (A) this;
    }

    public Boolean hasDestination(){
            return this.destination != null;
    }

    public EgressRuleFluent.DestinationNested withNewDestination(){
            return new DestinationNestedImpl();
    }

    public EgressRuleFluent.DestinationNested withNewDestinationLike(IstioService item){
            return new DestinationNestedImpl(item);
    }

    public EgressRuleFluent.DestinationNested editDestination(){
            return withNewDestinationLike(getDestination());
    }

    public EgressRuleFluent.DestinationNested editOrNewDestination(){
            return withNewDestinationLike(getDestination() != null ? getDestination(): new IstioServiceBuilder().build());
    }

    public EgressRuleFluent.DestinationNested editOrNewDestinationLike(IstioService item){
            return withNewDestinationLike(getDestination() != null ? getDestination(): item);
    }

    public A addToPorts(int index,me.snowdrop.istio.api.model.v1.routing.Port item){
            if (this.ports == null) {this.ports = new ArrayList();}
            me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.ports.add(index >= 0 ? index : ports.size(), builder); return (A)this;
    }

    public A setToPorts(int index,me.snowdrop.istio.api.model.v1.routing.Port item){
            if (this.ports == null) {this.ports = new ArrayList();}
            me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(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(me.snowdrop.istio.api.model.v1.routing.Port... items){
            if (this.ports == null) {this.ports = new ArrayList();}
            for (me.snowdrop.istio.api.model.v1.routing.Port item : items) {me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(item);_visitables.add(builder);this.ports.add(builder);} return (A)this;
    }

    public A addAllToPorts(Collection items){
            if (this.ports == null) {this.ports = new ArrayList();}
            for (me.snowdrop.istio.api.model.v1.routing.Port item : items) {me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(item);_visitables.add(builder);this.ports.add(builder);} return (A)this;
    }

    public A removeFromPorts(me.snowdrop.istio.api.model.v1.routing.Port... items){
            for (me.snowdrop.istio.api.model.v1.routing.Port item : items) {me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(item);_visitables.remove(builder);if (this.ports != null) {this.ports.remove(builder);}} return (A)this;
    }

    public A removeAllFromPorts(Collection items){
            for (me.snowdrop.istio.api.model.v1.routing.Port item : items) {me.snowdrop.istio.api.model.v1.routing.PortBuilder builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(item);_visitables.remove(builder);if (this.ports != null) {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 me.snowdrop.istio.api.model.v1.routing.Port buildPort(int index){
            return this.ports.get(index).build();
    }

    public me.snowdrop.istio.api.model.v1.routing.Port buildFirstPort(){
            return this.ports.get(0).build();
    }

    public me.snowdrop.istio.api.model.v1.routing.Port buildLastPort(){
            return this.ports.get(ports.size() - 1).build();
    }

    public me.snowdrop.istio.api.model.v1.routing.Port buildMatchingPort(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (me.snowdrop.istio.api.model.v1.routing.PortBuilder item: ports) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withPorts(List ports){
            if (this.ports != null) { _visitables.removeAll(this.ports);}
            if (ports != null) {this.ports = new ArrayList(); for (me.snowdrop.istio.api.model.v1.routing.Port item : ports){this.addToPorts(item);}} else { this.ports = null;} return (A) this;
    }

    public A withPorts(me.snowdrop.istio.api.model.v1.routing.Port... ports){
            this.ports.clear(); if (ports != null) {for (me.snowdrop.istio.api.model.v1.routing.Port item :ports){ this.addToPorts(item);}} return (A) this;
    }

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

    public A addNewPort(Integer port,String protocol){
            return (A)addToPorts(new Port(port, protocol));
    }

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

    public EgressRuleFluent.PortsNested addNewPortLike(me.snowdrop.istio.api.model.v1.routing.Port item){
            return new PortsNestedImpl(-1, item);
    }

    public EgressRuleFluent.PortsNested setNewPortLike(int index,me.snowdrop.istio.api.model.v1.routing.Port item){
            return new PortsNestedImpl(index, item);
    }

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

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

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

            private final IstioServiceBuilder builder;
    
            DestinationNestedImpl(IstioService item){
                    this.builder = new IstioServiceBuilder(this, item);
            }
            DestinationNestedImpl(){
                    this.builder = new IstioServiceBuilder(this);
            }
    
    public N and(){
            return (N) EgressRuleFluentImpl.this.withDestination(builder.build());
    }
    public N endDestination(){
            return and();
    }

}
    public class PortsNestedImpl extends me.snowdrop.istio.api.model.v1.routing.PortFluentImpl> implements EgressRuleFluent.PortsNested,io.fabric8.kubernetes.api.builder.Nested{

            private final me.snowdrop.istio.api.model.v1.routing.PortBuilder builder;
        private final int index;
    
            PortsNestedImpl(int index,me.snowdrop.istio.api.model.v1.routing.Port item){
                    this.index = index;
                    this.builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(this, item);
            }
            PortsNestedImpl(){
                    this.index = -1;
                    this.builder = new me.snowdrop.istio.api.model.v1.routing.PortBuilder(this);
            }
    
    public N and(){
            return (N) EgressRuleFluentImpl.this.setToPorts(index, builder.build());
    }
    public N endPort(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy