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

io.fabric8.kubernetes.api.model.PodDNSConfigFluentImpl Maven / Gradle / Ivy

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

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.lang.StringBuilder;
import com.fasterxml.jackson.annotation.JsonInclude;
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.StringBuffer;
import java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class PodDNSConfigFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements PodDNSConfigFluent{

    private List nameservers = new ArrayList();
    private List options =  new ArrayList();
    private List searches = new ArrayList();

    public PodDNSConfigFluentImpl(){
    }
    public PodDNSConfigFluentImpl(PodDNSConfig instance){
            this.withNameservers(instance.getNameservers()); 
            this.withOptions(instance.getOptions()); 
            this.withSearches(instance.getSearches()); 
    }

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

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

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

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

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

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

    public List getNameservers(){
            return this.nameservers;
    }

    public String getNameserver(int index){
            return this.nameservers.get(index);
    }

    public String getFirstNameserver(){
            return this.nameservers.get(0);
    }

    public String getLastNameserver(){
            return this.nameservers.get(nameservers.size() - 1);
    }

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

    public Boolean hasMatchingNameserver(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: nameservers) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withNameservers(List nameservers){
            if (this.nameservers != null) { _visitables.get("nameservers").removeAll(this.nameservers);}
            if (nameservers != null) {this.nameservers = new ArrayList(); for (String item : nameservers){this.addToNameservers(item);}} else { this.nameservers = null;} return (A) this;
    }

    public A withNameservers(String... nameservers){
            if (this.nameservers != null) {this.nameservers.clear();}
            if (nameservers != null) {for (String item :nameservers){ this.addToNameservers(item);}} return (A) this;
    }

    public Boolean hasNameservers(){
            return nameservers != null && !nameservers.isEmpty();
    }

    public A addNewNameserver(String arg1){
            return (A)addToNameservers(new String(arg1));
    }

    public A addNewNameserver(StringBuilder arg1){
            return (A)addToNameservers(new String(arg1));
    }

    public A addNewNameserver(StringBuffer arg1){
            return (A)addToNameservers(new String(arg1));
    }

    public A addToOptions(int index,PodDNSConfigOption item){
            if (this.options == null) {this.options = new ArrayList();}
            PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);_visitables.get("options").add(index >= 0 ? index : _visitables.get("options").size(), builder);this.options.add(index >= 0 ? index : options.size(), builder); return (A)this;
    }

    public A setToOptions(int index,PodDNSConfigOption item){
            if (this.options == null) {this.options = new ArrayList();}
            PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);
            if (index < 0 || index >= _visitables.get("options").size()) { _visitables.get("options").add(builder); } else { _visitables.get("options").set(index, builder);}
            if (index < 0 || index >= options.size()) { options.add(builder); } else { options.set(index, builder);}
             return (A)this;
    }

    public A addToOptions(PodDNSConfigOption... items){
            if (this.options == null) {this.options = new ArrayList();}
            for (PodDNSConfigOption item : items) {PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);_visitables.get("options").add(builder);this.options.add(builder);} return (A)this;
    }

    public A addAllToOptions(Collection items){
            if (this.options == null) {this.options = new ArrayList();}
            for (PodDNSConfigOption item : items) {PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);_visitables.get("options").add(builder);this.options.add(builder);} return (A)this;
    }

    public A removeFromOptions(PodDNSConfigOption... items){
            for (PodDNSConfigOption item : items) {PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);_visitables.get("options").remove(builder);if (this.options != null) {this.options.remove(builder);}} return (A)this;
    }

    public A removeAllFromOptions(Collection items){
            for (PodDNSConfigOption item : items) {PodDNSConfigOptionBuilder builder = new PodDNSConfigOptionBuilder(item);_visitables.get("options").remove(builder);if (this.options != null) {this.options.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromOptions(io.fabric8.kubernetes.api.builder.Predicate predicate){
            if (options == null) return (A) this;
            final Iterator each = options.iterator();
            final List visitables = _visitables.get("options");
            while (each.hasNext()) {
              PodDNSConfigOptionBuilder builder = each.next();
              if (predicate.apply(builder)) {
                visitables.remove(builder);
                each.remove();
              }
            }
            return (A)this;
    }

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

    public List buildOptions(){
            return build(options);
    }

    public PodDNSConfigOption buildOption(int index){
            return this.options.get(index).build();
    }

    public PodDNSConfigOption buildFirstOption(){
            return this.options.get(0).build();
    }

    public PodDNSConfigOption buildLastOption(){
            return this.options.get(options.size() - 1).build();
    }

    public PodDNSConfigOption buildMatchingOption(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (PodDNSConfigOptionBuilder item: options) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingOption(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (PodDNSConfigOptionBuilder item: options) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withOptions(List options){
            if (this.options != null) { _visitables.get("options").removeAll(this.options);}
            if (options != null) {this.options = new ArrayList(); for (PodDNSConfigOption item : options){this.addToOptions(item);}} else { this.options = null;} return (A) this;
    }

    public A withOptions(PodDNSConfigOption... options){
            if (this.options != null) {this.options.clear();}
            if (options != null) {for (PodDNSConfigOption item :options){ this.addToOptions(item);}} return (A) this;
    }

    public Boolean hasOptions(){
            return options != null && !options.isEmpty();
    }

    public A addNewOption(String name,String value){
            return (A)addToOptions(new PodDNSConfigOption(name, value));
    }

    public PodDNSConfigFluent.OptionsNested addNewOption(){
            return new OptionsNestedImpl();
    }

    public PodDNSConfigFluent.OptionsNested addNewOptionLike(PodDNSConfigOption item){
            return new OptionsNestedImpl(-1, item);
    }

    public PodDNSConfigFluent.OptionsNested setNewOptionLike(int index,PodDNSConfigOption item){
            return new OptionsNestedImpl(index, item);
    }

    public PodDNSConfigFluent.OptionsNested editOption(int index){
            if (options.size() <= index) throw new RuntimeException("Can't edit options. Index exceeds size.");
            return setNewOptionLike(index, buildOption(index));
    }

    public PodDNSConfigFluent.OptionsNested editFirstOption(){
            if (options.size() == 0) throw new RuntimeException("Can't edit first options. The list is empty.");
            return setNewOptionLike(0, buildOption(0));
    }

    public PodDNSConfigFluent.OptionsNested editLastOption(){
            int index = options.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last options. The list is empty.");
            return setNewOptionLike(index, buildOption(index));
    }

    public PodDNSConfigFluent.OptionsNested editMatchingOption(io.fabric8.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i();}
            this.searches.add(index, item);
            return (A)this;
    }

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

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

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

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

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

    public List getSearches(){
            return this.searches;
    }

    public String getSearch(int index){
            return this.searches.get(index);
    }

    public String getFirstSearch(){
            return this.searches.get(0);
    }

    public String getLastSearch(){
            return this.searches.get(searches.size() - 1);
    }

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

    public Boolean hasMatchingSearch(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (String item: searches) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withSearches(List searches){
            if (this.searches != null) { _visitables.get("searches").removeAll(this.searches);}
            if (searches != null) {this.searches = new ArrayList(); for (String item : searches){this.addToSearches(item);}} else { this.searches = null;} return (A) this;
    }

    public A withSearches(String... searches){
            if (this.searches != null) {this.searches.clear();}
            if (searches != null) {for (String item :searches){ this.addToSearches(item);}} return (A) this;
    }

    public Boolean hasSearches(){
            return searches != null && !searches.isEmpty();
    }

    public A addNewSearch(String arg1){
            return (A)addToSearches(new String(arg1));
    }

    public A addNewSearch(StringBuilder arg1){
            return (A)addToSearches(new String(arg1));
    }

    public A addNewSearch(StringBuffer arg1){
            return (A)addToSearches(new String(arg1));
    }

    public boolean equals(Object o){
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            PodDNSConfigFluentImpl that = (PodDNSConfigFluentImpl) o;
            if (nameservers != null ? !nameservers.equals(that.nameservers) :that.nameservers != null) return false;
            if (options != null ? !options.equals(that.options) :that.options != null) return false;
            if (searches != null ? !searches.equals(that.searches) :that.searches != null) return false;
            return true;
    }


    public class OptionsNestedImpl extends PodDNSConfigOptionFluentImpl> implements PodDNSConfigFluent.OptionsNested,io.fabric8.kubernetes.api.builder.Nested{

            private final PodDNSConfigOptionBuilder builder;
        private final int index;
    
            OptionsNestedImpl(int index,PodDNSConfigOption item){
                    this.index = index;
                    this.builder = new PodDNSConfigOptionBuilder(this, item);
            }
            OptionsNestedImpl(){
                    this.index = -1;
                    this.builder = new PodDNSConfigOptionBuilder(this);
            }
    
    public N and(){
            return (N) PodDNSConfigFluentImpl.this.setToOptions(index,builder.build());
    }
    public N endOption(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy