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 java.util.ArrayList;
import me.snowdrop.istio.api.builder.Nested;
import java.lang.String;
import me.snowdrop.istio.api.builder.Predicate;
import java.lang.Deprecated;
import me.snowdrop.istio.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 me.snowdrop.istio.api.builder.BaseFluent implements EgressRuleFluent{
private IstioServiceBuilder destination;
private List ports = new ArrayList();
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,Port item){
if (this.ports == null) {this.ports = new ArrayList();}
PortBuilder builder = new 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,Port item){
if (this.ports == null) {this.ports = new ArrayList();}
PortBuilder builder = new 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(Port... items){
if (this.ports == null) {this.ports = new ArrayList();}
for (Port item : items) {PortBuilder builder = new 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 (Port item : items) {PortBuilder builder = new PortBuilder(item);_visitables.add(builder);this.ports.add(builder);} return (A)this;
}
public A removeFromPorts(Port... items){
for (Port item : items) {PortBuilder builder = new PortBuilder(item);_visitables.remove(builder);if (this.ports != null) {this.ports.remove(builder);}} return (A)this;
}
public A removeAllFromPorts(Collection items){
for (Port item : items) {PortBuilder builder = new 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 Port buildPort(int index){
return this.ports.get(index).build();
}
public Port buildFirstPort(){
return this.ports.get(0).build();
}
public Port buildLastPort(){
return this.ports.get(ports.size() - 1).build();
}
public Port buildMatchingPort(me.snowdrop.istio.api.builder.Predicate predicate){
for (PortBuilder item: ports) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withPorts(List ports){
if (this.ports == null) { this.ports = new ArrayList();} else {_visitables.removeAll(this.ports); this.ports.clear();}
if (ports != null) {for (Port item : ports){this.addToPorts(item);}} return (A) this;
}
public A withPorts(Port... ports){
this.ports.clear(); if (ports != null) {for (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(Port item){
return new PortsNestedImpl(-1, item);
}
public EgressRuleFluent.PortsNested setNewPortLike(int index,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(me.snowdrop.istio.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends IstioServiceFluentImpl> implements EgressRuleFluent.DestinationNested,me.snowdrop.istio.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 PortFluentImpl> implements EgressRuleFluent.PortsNested,me.snowdrop.istio.api.builder.Nested{
private final PortBuilder builder;
private final int index;
PortsNestedImpl(int index,Port item){
this.index = index;
this.builder = new PortBuilder(this, item);
}
PortsNestedImpl(){
this.index = -1;
this.builder = new 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