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

me.snowdrop.istio.api.rbac.v1alpha1.TargetFluentImpl Maven / Gradle / Ivy

package me.snowdrop.istio.api.rbac.v1alpha1;

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 javax.validation.Valid;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class TargetFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements TargetFluent{

    private List namespaces;
    private List services;
    private List workloadSelectors;

    public TargetFluentImpl(){
    }
    public TargetFluentImpl(Target instance){
            this.withNamespaces(instance.getNamespaces()); 
            this.withServices(instance.getServices()); 
            this.withWorkloadSelectors(instance.getWorkloadSelectors()); 
    }

    public A addToNamespaces(int index,String item){
            if (this.namespaces == null) {this.namespaces = new ArrayList();}
            this.namespaces.add(index, item);
            return (A)this;
    }

    public A setToNamespaces(int index,String item){
            if (this.namespaces == null) {this.namespaces = new ArrayList();}
            this.namespaces.set(index, item); return (A)this;
    }

    public A addToNamespaces(String... items){
            if (this.namespaces == null) {this.namespaces = new ArrayList();}
            for (String item : items) {this.namespaces.add(item);} return (A)this;
    }

    public A addAllToNamespaces(Collection items){
            if (this.namespaces == null) {this.namespaces = new ArrayList();}
            for (String item : items) {this.namespaces.add(item);} return (A)this;
    }

    public A removeFromNamespaces(String... items){
            for (String item : items) {if (this.namespaces!= null){ this.namespaces.remove(item);}} return (A)this;
    }

    public A removeAllFromNamespaces(Collection items){
            for (String item : items) {if (this.namespaces!= null){ this.namespaces.remove(item);}} return (A)this;
    }

    public List getNamespaces(){
            return this.namespaces;
    }

    public String getNamespace(int index){
            return this.namespaces.get(index);
    }

    public String getFirstNamespace(){
            return this.namespaces.get(0);
    }

    public String getLastNamespace(){
            return this.namespaces.get(namespaces.size() - 1);
    }

    public String getMatchingNamespace(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: namespaces) { if(predicate.apply(item)){return item;} } return null;
    }

    public A withNamespaces(List namespaces){
            if (this.namespaces != null) { _visitables.removeAll(this.namespaces);}
            if (namespaces != null) {this.namespaces = new ArrayList(); for (String item : namespaces){this.addToNamespaces(item);}} else { this.namespaces = null;} return (A) this;
    }

    public A withNamespaces(String... namespaces){
            if (this.namespaces != null) {this.namespaces.clear();}
            if (namespaces != null) {for (String item :namespaces){ this.addToNamespaces(item);}} return (A) this;
    }

    public Boolean hasNamespaces(){
            return namespaces != null && !namespaces.isEmpty();
    }

    public A addToServices(int index,String item){
            if (this.services == null) {this.services = new ArrayList();}
            this.services.add(index, item);
            return (A)this;
    }

    public A setToServices(int index,String item){
            if (this.services == null) {this.services = new ArrayList();}
            this.services.set(index, item); return (A)this;
    }

    public A addToServices(String... items){
            if (this.services == null) {this.services = new ArrayList();}
            for (String item : items) {this.services.add(item);} return (A)this;
    }

    public A addAllToServices(Collection items){
            if (this.services == null) {this.services = new ArrayList();}
            for (String item : items) {this.services.add(item);} return (A)this;
    }

    public A removeFromServices(String... items){
            for (String item : items) {if (this.services!= null){ this.services.remove(item);}} return (A)this;
    }

    public A removeAllFromServices(Collection items){
            for (String item : items) {if (this.services!= null){ this.services.remove(item);}} return (A)this;
    }

    public List getServices(){
            return this.services;
    }

    public String getService(int index){
            return this.services.get(index);
    }

    public String getFirstService(){
            return this.services.get(0);
    }

    public String getLastService(){
            return this.services.get(services.size() - 1);
    }

    public String getMatchingService(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: services) { if(predicate.apply(item)){return item;} } return null;
    }

    public A withServices(List services){
            if (this.services != null) { _visitables.removeAll(this.services);}
            if (services != null) {this.services = new ArrayList(); for (String item : services){this.addToServices(item);}} else { this.services = null;} return (A) this;
    }

    public A withServices(String... services){
            if (this.services != null) {this.services.clear();}
            if (services != null) {for (String item :services){ this.addToServices(item);}} return (A) this;
    }

    public Boolean hasServices(){
            return services != null && !services.isEmpty();
    }

    public A addToWorkloadSelectors(int index,me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item){
            if (this.workloadSelectors == null) {this.workloadSelectors = new ArrayList();}
            me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.workloadSelectors.add(index >= 0 ? index : workloadSelectors.size(), builder); return (A)this;
    }

    public A setToWorkloadSelectors(int index,me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item){
            if (this.workloadSelectors == null) {this.workloadSelectors = new ArrayList();}
            me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= workloadSelectors.size()) { workloadSelectors.add(builder); } else { workloadSelectors.set(index, builder);}
             return (A)this;
    }

    public A addToWorkloadSelectors(me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector... items){
            if (this.workloadSelectors == null) {this.workloadSelectors = new ArrayList();}
            for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item : items) {me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);_visitables.add(builder);this.workloadSelectors.add(builder);} return (A)this;
    }

    public A addAllToWorkloadSelectors(Collection items){
            if (this.workloadSelectors == null) {this.workloadSelectors = new ArrayList();}
            for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item : items) {me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);_visitables.add(builder);this.workloadSelectors.add(builder);} return (A)this;
    }

    public A removeFromWorkloadSelectors(me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector... items){
            for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item : items) {me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);_visitables.remove(builder);if (this.workloadSelectors != null) {this.workloadSelectors.remove(builder);}} return (A)this;
    }

    public A removeAllFromWorkloadSelectors(Collection items){
            for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item : items) {me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(item);_visitables.remove(builder);if (this.workloadSelectors != null) {this.workloadSelectors.remove(builder);}} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildWorkloadSelectors instead.
 * @return The buildable object.
 */
@Deprecated public List getWorkloadSelectors(){
            return build(workloadSelectors);
    }

    public List buildWorkloadSelectors(){
            return build(workloadSelectors);
    }

    public me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector buildWorkloadSelector(int index){
            return this.workloadSelectors.get(index).build();
    }

    public me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector buildFirstWorkloadSelector(){
            return this.workloadSelectors.get(0).build();
    }

    public me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector buildLastWorkloadSelector(){
            return this.workloadSelectors.get(workloadSelectors.size() - 1).build();
    }

    public me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector buildMatchingWorkloadSelector(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder item: workloadSelectors) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withWorkloadSelectors(List workloadSelectors){
            if (this.workloadSelectors != null) { _visitables.removeAll(this.workloadSelectors);}
            if (workloadSelectors != null) {this.workloadSelectors = new ArrayList(); for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item : workloadSelectors){this.addToWorkloadSelectors(item);}} else { this.workloadSelectors = null;} return (A) this;
    }

    public A withWorkloadSelectors(me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector... workloadSelectors){
            if (this.workloadSelectors != null) {this.workloadSelectors.clear();}
            if (workloadSelectors != null) {for (me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item :workloadSelectors){ this.addToWorkloadSelectors(item);}} return (A) this;
    }

    public Boolean hasWorkloadSelectors(){
            return workloadSelectors != null && !workloadSelectors.isEmpty();
    }

    public TargetFluent.WorkloadSelectorsNested addNewWorkloadSelector(){
            return new WorkloadSelectorsNestedImpl();
    }

    public TargetFluent.WorkloadSelectorsNested addNewWorkloadSelectorLike(me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item){
            return new WorkloadSelectorsNestedImpl(-1, item);
    }

    public TargetFluent.WorkloadSelectorsNested setNewWorkloadSelectorLike(int index,me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item){
            return new WorkloadSelectorsNestedImpl(index, item);
    }

    public TargetFluent.WorkloadSelectorsNested editWorkloadSelector(int index){
            if (workloadSelectors.size() <= index) throw new RuntimeException("Can't edit workloadSelectors. Index exceeds size.");
            return setNewWorkloadSelectorLike(index, buildWorkloadSelector(index));
    }

    public TargetFluent.WorkloadSelectorsNested editFirstWorkloadSelector(){
            if (workloadSelectors.size() == 0) throw new RuntimeException("Can't edit first workloadSelectors. The list is empty.");
            return setNewWorkloadSelectorLike(0, buildWorkloadSelector(0));
    }

    public TargetFluent.WorkloadSelectorsNested editLastWorkloadSelector(){
            int index = workloadSelectors.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last workloadSelectors. The list is empty.");
            return setNewWorkloadSelectorLike(index, buildWorkloadSelector(index));
    }

    public TargetFluent.WorkloadSelectorsNested editMatchingWorkloadSelector(io.fabric8.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorFluentImpl> implements TargetFluent.WorkloadSelectorsNested,io.fabric8.kubernetes.api.builder.Nested{

            private final me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder builder;
        private final int index;
    
            WorkloadSelectorsNestedImpl(int index,me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelector item){
                    this.index = index;
                    this.builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(this, item);
            }
            WorkloadSelectorsNestedImpl(){
                    this.index = -1;
                    this.builder = new me.snowdrop.istio.api.rbac.v1alpha1.WorkloadSelectorBuilder(this);
            }
    
    public N and(){
            return (N) TargetFluentImpl.this.setToWorkloadSelectors(index, builder.build());
    }
    public N endWorkloadSelector(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy