io.fabric8.kubernetes.api.model.ContextFluentImpl Maven / Gradle / Ivy
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 ContextFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements ContextFluent{
private String cluster;
private List extensions = new ArrayList();
private String namespace;
private String user;
public ContextFluentImpl(){
}
public ContextFluentImpl(Context instance){
this.withCluster(instance.getCluster());
this.withExtensions(instance.getExtensions());
this.withNamespace(instance.getNamespace());
this.withUser(instance.getUser());
}
public String getCluster(){
return this.cluster;
}
public A withCluster(String cluster){
this.cluster=cluster; return (A) this;
}
public Boolean hasCluster(){
return this.cluster != null;
}
public A withNewCluster(String arg1){
return (A)withCluster(new String(arg1));
}
public A withNewCluster(StringBuilder arg1){
return (A)withCluster(new String(arg1));
}
public A withNewCluster(StringBuffer arg1){
return (A)withCluster(new String(arg1));
}
public A addToExtensions(int index,NamedExtension item){
if (this.extensions == null) {this.extensions = new ArrayList();}
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.get("extensions").add(index >= 0 ? index : _visitables.get("extensions").size(), builder);this.extensions.add(index >= 0 ? index : extensions.size(), builder); return (A)this;
}
public A setToExtensions(int index,NamedExtension item){
if (this.extensions == null) {this.extensions = new ArrayList();}
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);
if (index < 0 || index >= _visitables.get("extensions").size()) { _visitables.get("extensions").add(builder); } else { _visitables.get("extensions").set(index, builder);}
if (index < 0 || index >= extensions.size()) { extensions.add(builder); } else { extensions.set(index, builder);}
return (A)this;
}
public A addToExtensions(NamedExtension... items){
if (this.extensions == null) {this.extensions = new ArrayList();}
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.get("extensions").add(builder);this.extensions.add(builder);} return (A)this;
}
public A addAllToExtensions(Collection items){
if (this.extensions == null) {this.extensions = new ArrayList();}
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.get("extensions").add(builder);this.extensions.add(builder);} return (A)this;
}
public A removeFromExtensions(NamedExtension... items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.get("extensions").remove(builder);if (this.extensions != null) {this.extensions.remove(builder);}} return (A)this;
}
public A removeAllFromExtensions(Collection items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.get("extensions").remove(builder);if (this.extensions != null) {this.extensions.remove(builder);}} return (A)this;
}
public A removeMatchingFromExtensions(io.fabric8.kubernetes.api.builder.Predicate predicate){
if (extensions == null) return (A) this;
final Iterator each = extensions.iterator();
final List visitables = _visitables.get("extensions");
while (each.hasNext()) {
NamedExtensionBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
/**
* This method has been deprecated, please use method buildExtensions instead.
* @return The buildable object.
*/
@Deprecated public List getExtensions(){
return build(extensions);
}
public List buildExtensions(){
return build(extensions);
}
public NamedExtension buildExtension(int index){
return this.extensions.get(index).build();
}
public NamedExtension buildFirstExtension(){
return this.extensions.get(0).build();
}
public NamedExtension buildLastExtension(){
return this.extensions.get(extensions.size() - 1).build();
}
public NamedExtension buildMatchingExtension(io.fabric8.kubernetes.api.builder.Predicate predicate){
for (NamedExtensionBuilder item: extensions) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingExtension(io.fabric8.kubernetes.api.builder.Predicate predicate){
for (NamedExtensionBuilder item: extensions) { if(predicate.apply(item)){ return true;} } return false;
}
public A withExtensions(List extensions){
if (this.extensions != null) { _visitables.get("extensions").removeAll(this.extensions);}
if (extensions != null) {this.extensions = new ArrayList(); for (NamedExtension item : extensions){this.addToExtensions(item);}} else { this.extensions = null;} return (A) this;
}
public A withExtensions(NamedExtension... extensions){
if (this.extensions != null) {this.extensions.clear();}
if (extensions != null) {for (NamedExtension item :extensions){ this.addToExtensions(item);}} return (A) this;
}
public Boolean hasExtensions(){
return extensions != null && !extensions.isEmpty();
}
public ContextFluent.ExtensionsNested addNewExtension(){
return new ExtensionsNestedImpl();
}
public ContextFluent.ExtensionsNested addNewExtensionLike(NamedExtension item){
return new ExtensionsNestedImpl(-1, item);
}
public ContextFluent.ExtensionsNested setNewExtensionLike(int index,NamedExtension item){
return new ExtensionsNestedImpl(index, item);
}
public ContextFluent.ExtensionsNested editExtension(int index){
if (extensions.size() <= index) throw new RuntimeException("Can't edit extensions. Index exceeds size.");
return setNewExtensionLike(index, buildExtension(index));
}
public ContextFluent.ExtensionsNested editFirstExtension(){
if (extensions.size() == 0) throw new RuntimeException("Can't edit first extensions. The list is empty.");
return setNewExtensionLike(0, buildExtension(0));
}
public ContextFluent.ExtensionsNested editLastExtension(){
int index = extensions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last extensions. The list is empty.");
return setNewExtensionLike(index, buildExtension(index));
}
public ContextFluent.ExtensionsNested editMatchingExtension(io.fabric8.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends NamedExtensionFluentImpl> implements ContextFluent.ExtensionsNested,io.fabric8.kubernetes.api.builder.Nested{
private final NamedExtensionBuilder builder;
private final int index;
ExtensionsNestedImpl(int index,NamedExtension item){
this.index = index;
this.builder = new NamedExtensionBuilder(this, item);
}
ExtensionsNestedImpl(){
this.index = -1;
this.builder = new NamedExtensionBuilder(this);
}
public N and(){
return (N) ContextFluentImpl.this.setToExtensions(index,builder.build());
}
public N endExtension(){
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy