io.kubernetes.client.openapi.models.V1PodDNSConfigFluentImpl Maven / Gradle / Ivy
package io.kubernetes.client.openapi.models;
import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.StringBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kubernetes.client.fluent.Predicate;
import java.lang.StringBuffer;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class V1PodDNSConfigFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1PodDNSConfigFluent {
private List nameservers;
private List options;
private List searches;
public V1PodDNSConfigFluentImpl() {
}
public V1PodDNSConfigFluentImpl(V1PodDNSConfig 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.kubernetes.client.fluent.Predicate predicate) {
for (String item: nameservers) { if(predicate.apply(item)){ return item;} } return null;
}
public Boolean hasMatchingNameserver(io.kubernetes.client.fluent.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,V1PodDNSConfigOption item) {
if (this.options == null) {this.options = new ArrayList();}
V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(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,V1PodDNSConfigOption item) {
if (this.options == null) {this.options = new ArrayList();}
V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(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(V1PodDNSConfigOption... items) {
if (this.options == null) {this.options = new ArrayList();}
for (V1PodDNSConfigOption item : items) {V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(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 (V1PodDNSConfigOption item : items) {V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(item);_visitables.get("options").add(builder);this.options.add(builder);} return (A)this;
}
public A removeFromOptions(V1PodDNSConfigOption... items) {
for (V1PodDNSConfigOption item : items) {V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(item);_visitables.get("options").remove(builder);if (this.options != null) {this.options.remove(builder);}} return (A)this;
}
public A removeAllFromOptions(Collection items) {
for (V1PodDNSConfigOption item : items) {V1PodDNSConfigOptionBuilder builder = new V1PodDNSConfigOptionBuilder(item);_visitables.get("options").remove(builder);if (this.options != null) {this.options.remove(builder);}} return (A)this;
}
public A removeMatchingFromOptions(io.kubernetes.client.fluent.Predicate predicate) {
if (options == null) return (A) this;
final Iterator each = options.iterator();
final List visitables = _visitables.get("options");
while (each.hasNext()) {
V1PodDNSConfigOptionBuilder 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 V1PodDNSConfigOption buildOption(int index) {
return this.options.get(index).build();
}
public V1PodDNSConfigOption buildFirstOption() {
return this.options.get(0).build();
}
public V1PodDNSConfigOption buildLastOption() {
return this.options.get(options.size() - 1).build();
}
public V1PodDNSConfigOption buildMatchingOption(io.kubernetes.client.fluent.Predicate predicate) {
for (V1PodDNSConfigOptionBuilder item: options) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingOption(io.kubernetes.client.fluent.Predicate predicate) {
for (V1PodDNSConfigOptionBuilder 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 (V1PodDNSConfigOption item : options){this.addToOptions(item);}} else { this.options = null;} return (A) this;
}
public A withOptions(V1PodDNSConfigOption... options) {
if (this.options != null) {this.options.clear();}
if (options != null) {for (V1PodDNSConfigOption item :options){ this.addToOptions(item);}} return (A) this;
}
public Boolean hasOptions() {
return options != null && !options.isEmpty();
}
public V1PodDNSConfigFluent.OptionsNested addNewOption() {
return new OptionsNestedImpl();
}
public V1PodDNSConfigFluent.OptionsNested addNewOptionLike(V1PodDNSConfigOption item) {
return new OptionsNestedImpl(-1, item);
}
public V1PodDNSConfigFluent.OptionsNested setNewOptionLike(int index,V1PodDNSConfigOption item) {
return new OptionsNestedImpl(index, item);
}
public V1PodDNSConfigFluent.OptionsNested editOption(int index) {
if (options.size() <= index) throw new RuntimeException("Can't edit options. Index exceeds size.");
return setNewOptionLike(index, buildOption(index));
}
public V1PodDNSConfigFluent.OptionsNested editFirstOption() {
if (options.size() == 0) throw new RuntimeException("Can't edit first options. The list is empty.");
return setNewOptionLike(0, buildOption(0));
}
public V1PodDNSConfigFluent.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 V1PodDNSConfigFluent.OptionsNested editMatchingOption(io.kubernetes.client.fluent.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.kubernetes.client.fluent.Predicate predicate) {
for (String item: searches) { if(predicate.apply(item)){ return item;} } return null;
}
public Boolean hasMatchingSearch(io.kubernetes.client.fluent.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;
V1PodDNSConfigFluentImpl that = (V1PodDNSConfigFluentImpl) 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 int hashCode() {
return java.util.Objects.hash(nameservers, options, searches, super.hashCode());
}
public class OptionsNestedImpl extends V1PodDNSConfigOptionFluentImpl> implements V1PodDNSConfigFluent.OptionsNested,io.kubernetes.client.fluent.Nested {
private final V1PodDNSConfigOptionBuilder builder;
private final int index;
OptionsNestedImpl(int index,V1PodDNSConfigOption item) {
this.index = index;
this.builder = new V1PodDNSConfigOptionBuilder(this, item);
}
OptionsNestedImpl() {
this.index = -1;
this.builder = new V1PodDNSConfigOptionBuilder(this);
}
public N and() {
return (N) V1PodDNSConfigFluentImpl.this.setToOptions(index,builder.build());
}
public N endOption() {
return and();
}
}
}