io.alauda.kubernetes.api.model.ConfigFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import javax.validation.constraints.NotNull;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;
public class ConfigFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ConfigFluent{
private String apiVersion;
private List clusters = new ArrayList();
private List contexts = new ArrayList();
private String currentContext;
private List extensions = new ArrayList();
private String kind;
private PreferencesBuilder preferences;
private List users = new ArrayList();
public ConfigFluentImpl(){
}
public ConfigFluentImpl(Config instance){
this.withApiVersion(instance.getApiVersion());
this.withClusters(instance.getClusters());
this.withContexts(instance.getContexts());
this.withCurrentContext(instance.getCurrentContext());
this.withExtensions(instance.getExtensions());
this.withKind(instance.getKind());
this.withPreferences(instance.getPreferences());
this.withUsers(instance.getUsers());
}
public String getApiVersion(){
return this.apiVersion;
}
public A withApiVersion(String apiVersion){
this.apiVersion=apiVersion; return (A) this;
}
public Boolean hasApiVersion(){
return this.apiVersion!=null;
}
public A addToClusters(int index,NamedCluster item){
NamedClusterBuilder builder = new NamedClusterBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.clusters.add(index >= 0 ? index : clusters.size(), builder); return (A)this;
}
public A setToClusters(int index,NamedCluster item){
NamedClusterBuilder builder = new NamedClusterBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= clusters.size()) { clusters.add(builder); } else { clusters.set(index, builder);}
return (A)this;
}
public A addToClusters(NamedCluster... items){
for (NamedCluster item : items) {NamedClusterBuilder builder = new NamedClusterBuilder(item);_visitables.add(builder);this.clusters.add(builder);} return (A)this;
}
public A addAllToClusters(Collection items){
for (NamedCluster item : items) {NamedClusterBuilder builder = new NamedClusterBuilder(item);_visitables.add(builder);this.clusters.add(builder);} return (A)this;
}
public A removeFromClusters(NamedCluster... items){
for (NamedCluster item : items) {NamedClusterBuilder builder = new NamedClusterBuilder(item);_visitables.remove(builder);this.clusters.remove(builder);} return (A)this;
}
public A removeAllFromClusters(Collection items){
for (NamedCluster item : items) {NamedClusterBuilder builder = new NamedClusterBuilder(item);_visitables.remove(builder);this.clusters.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildClusters instead.
*/
@Deprecated public List getClusters(){
return build(clusters);
}
public List buildClusters(){
return build(clusters);
}
public NamedCluster buildCluster(int index){
return this.clusters.get(index).build();
}
public NamedCluster buildFirstCluster(){
return this.clusters.get(0).build();
}
public NamedCluster buildLastCluster(){
return this.clusters.get(clusters.size() - 1).build();
}
public NamedCluster buildMatchingCluster(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedClusterBuilder item: clusters) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withClusters(List clusters){
_visitables.removeAll(this.clusters);
this.clusters.clear();
if (clusters != null) {for (NamedCluster item : clusters){this.addToClusters(item);}} return (A) this;
}
public A withClusters(NamedCluster... clusters){
this.clusters.clear(); if (clusters != null) {for (NamedCluster item :clusters){ this.addToClusters(item);}} return (A) this;
}
public Boolean hasClusters(){
return clusters!= null && !clusters.isEmpty();
}
public ConfigFluent.ClustersNested addNewCluster(){
return new ClustersNestedImpl();
}
public ConfigFluent.ClustersNested addNewClusterLike(NamedCluster item){
return new ClustersNestedImpl(-1, item);
}
public ConfigFluent.ClustersNested setNewClusterLike(int index,NamedCluster item){
return new ClustersNestedImpl(index, item);
}
public ConfigFluent.ClustersNested editCluster(int index){
if (clusters.size() <= index) throw new RuntimeException("Can't edit clusters. Index exceeds size.");
return setNewClusterLike(index, buildCluster(index));
}
public ConfigFluent.ClustersNested editFirstCluster(){
if (clusters.size() == 0) throw new RuntimeException("Can't edit first clusters. The list is empty.");
return setNewClusterLike(0, buildCluster(0));
}
public ConfigFluent.ClustersNested editLastCluster(){
int index = clusters.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last clusters. The list is empty.");
return setNewClusterLike(index, buildCluster(index));
}
public ConfigFluent.ClustersNested editMatchingCluster(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i= 0 ? index : _visitables.size(), builder);this.contexts.add(index >= 0 ? index : contexts.size(), builder); return (A)this;
}
public A setToContexts(int index,NamedContext item){
NamedContextBuilder builder = new NamedContextBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= contexts.size()) { contexts.add(builder); } else { contexts.set(index, builder);}
return (A)this;
}
public A addToContexts(NamedContext... items){
for (NamedContext item : items) {NamedContextBuilder builder = new NamedContextBuilder(item);_visitables.add(builder);this.contexts.add(builder);} return (A)this;
}
public A addAllToContexts(Collection items){
for (NamedContext item : items) {NamedContextBuilder builder = new NamedContextBuilder(item);_visitables.add(builder);this.contexts.add(builder);} return (A)this;
}
public A removeFromContexts(NamedContext... items){
for (NamedContext item : items) {NamedContextBuilder builder = new NamedContextBuilder(item);_visitables.remove(builder);this.contexts.remove(builder);} return (A)this;
}
public A removeAllFromContexts(Collection items){
for (NamedContext item : items) {NamedContextBuilder builder = new NamedContextBuilder(item);_visitables.remove(builder);this.contexts.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildContexts instead.
*/
@Deprecated public List getContexts(){
return build(contexts);
}
public List buildContexts(){
return build(contexts);
}
public NamedContext buildContext(int index){
return this.contexts.get(index).build();
}
public NamedContext buildFirstContext(){
return this.contexts.get(0).build();
}
public NamedContext buildLastContext(){
return this.contexts.get(contexts.size() - 1).build();
}
public NamedContext buildMatchingContext(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedContextBuilder item: contexts) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withContexts(List contexts){
_visitables.removeAll(this.contexts);
this.contexts.clear();
if (contexts != null) {for (NamedContext item : contexts){this.addToContexts(item);}} return (A) this;
}
public A withContexts(NamedContext... contexts){
this.contexts.clear(); if (contexts != null) {for (NamedContext item :contexts){ this.addToContexts(item);}} return (A) this;
}
public Boolean hasContexts(){
return contexts!= null && !contexts.isEmpty();
}
public ConfigFluent.ContextsNested addNewContext(){
return new ContextsNestedImpl();
}
public ConfigFluent.ContextsNested addNewContextLike(NamedContext item){
return new ContextsNestedImpl(-1, item);
}
public ConfigFluent.ContextsNested setNewContextLike(int index,NamedContext item){
return new ContextsNestedImpl(index, item);
}
public ConfigFluent.ContextsNested editContext(int index){
if (contexts.size() <= index) throw new RuntimeException("Can't edit contexts. Index exceeds size.");
return setNewContextLike(index, buildContext(index));
}
public ConfigFluent.ContextsNested editFirstContext(){
if (contexts.size() == 0) throw new RuntimeException("Can't edit first contexts. The list is empty.");
return setNewContextLike(0, buildContext(0));
}
public ConfigFluent.ContextsNested editLastContext(){
int index = contexts.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last contexts. The list is empty.");
return setNewContextLike(index, buildContext(index));
}
public ConfigFluent.ContextsNested editMatchingContext(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i= 0 ? index : _visitables.size(), builder);this.extensions.add(index >= 0 ? index : extensions.size(), builder); return (A)this;
}
public A setToExtensions(int index,NamedExtension item){
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.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){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(builder);this.extensions.add(builder);} return (A)this;
}
public A addAllToExtensions(Collection items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(builder);this.extensions.add(builder);} return (A)this;
}
public A removeFromExtensions(NamedExtension... items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.remove(builder);this.extensions.remove(builder);} return (A)this;
}
public A removeAllFromExtensions(Collection items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.remove(builder);this.extensions.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildExtensions instead.
*/
@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.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedExtensionBuilder item: extensions) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withExtensions(List extensions){
_visitables.removeAll(this.extensions);
this.extensions.clear();
if (extensions != null) {for (NamedExtension item : extensions){this.addToExtensions(item);}} return (A) this;
}
public A withExtensions(NamedExtension... extensions){
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 ConfigFluent.ExtensionsNested addNewExtension(){
return new ExtensionsNestedImpl();
}
public ConfigFluent.ExtensionsNested addNewExtensionLike(NamedExtension item){
return new ExtensionsNestedImpl(-1, item);
}
public ConfigFluent.ExtensionsNested setNewExtensionLike(int index,NamedExtension item){
return new ExtensionsNestedImpl(index, item);
}
public ConfigFluent.ExtensionsNested editExtension(int index){
if (extensions.size() <= index) throw new RuntimeException("Can't edit extensions. Index exceeds size.");
return setNewExtensionLike(index, buildExtension(index));
}
public ConfigFluent.ExtensionsNested editFirstExtension(){
if (extensions.size() == 0) throw new RuntimeException("Can't edit first extensions. The list is empty.");
return setNewExtensionLike(0, buildExtension(0));
}
public ConfigFluent.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 ConfigFluent.ExtensionsNested editMatchingExtension(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewPreferences(){
return new PreferencesNestedImpl();
}
public ConfigFluent.PreferencesNested withNewPreferencesLike(Preferences item){
return new PreferencesNestedImpl(item);
}
public ConfigFluent.PreferencesNested editPreferences(){
return withNewPreferencesLike(getPreferences());
}
public ConfigFluent.PreferencesNested editOrNewPreferences(){
return withNewPreferencesLike(getPreferences() != null ? getPreferences(): new PreferencesBuilder().build());
}
public ConfigFluent.PreferencesNested editOrNewPreferencesLike(Preferences item){
return withNewPreferencesLike(getPreferences() != null ? getPreferences(): item);
}
public A addToUsers(int index,NamedAuthInfo item){
NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.users.add(index >= 0 ? index : users.size(), builder); return (A)this;
}
public A setToUsers(int index,NamedAuthInfo item){
NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= users.size()) { users.add(builder); } else { users.set(index, builder);}
return (A)this;
}
public A addToUsers(NamedAuthInfo... items){
for (NamedAuthInfo item : items) {NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);_visitables.add(builder);this.users.add(builder);} return (A)this;
}
public A addAllToUsers(Collection items){
for (NamedAuthInfo item : items) {NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);_visitables.add(builder);this.users.add(builder);} return (A)this;
}
public A removeFromUsers(NamedAuthInfo... items){
for (NamedAuthInfo item : items) {NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);_visitables.remove(builder);this.users.remove(builder);} return (A)this;
}
public A removeAllFromUsers(Collection items){
for (NamedAuthInfo item : items) {NamedAuthInfoBuilder builder = new NamedAuthInfoBuilder(item);_visitables.remove(builder);this.users.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildUsers instead.
*/
@Deprecated public List getUsers(){
return build(users);
}
public List buildUsers(){
return build(users);
}
public NamedAuthInfo buildUser(int index){
return this.users.get(index).build();
}
public NamedAuthInfo buildFirstUser(){
return this.users.get(0).build();
}
public NamedAuthInfo buildLastUser(){
return this.users.get(users.size() - 1).build();
}
public NamedAuthInfo buildMatchingUser(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedAuthInfoBuilder item: users) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withUsers(List users){
_visitables.removeAll(this.users);
this.users.clear();
if (users != null) {for (NamedAuthInfo item : users){this.addToUsers(item);}} return (A) this;
}
public A withUsers(NamedAuthInfo... users){
this.users.clear(); if (users != null) {for (NamedAuthInfo item :users){ this.addToUsers(item);}} return (A) this;
}
public Boolean hasUsers(){
return users!= null && !users.isEmpty();
}
public ConfigFluent.UsersNested addNewUser(){
return new UsersNestedImpl();
}
public ConfigFluent.UsersNested addNewUserLike(NamedAuthInfo item){
return new UsersNestedImpl(-1, item);
}
public ConfigFluent.UsersNested setNewUserLike(int index,NamedAuthInfo item){
return new UsersNestedImpl(index, item);
}
public ConfigFluent.UsersNested editUser(int index){
if (users.size() <= index) throw new RuntimeException("Can't edit users. Index exceeds size.");
return setNewUserLike(index, buildUser(index));
}
public ConfigFluent.UsersNested editFirstUser(){
if (users.size() == 0) throw new RuntimeException("Can't edit first users. The list is empty.");
return setNewUserLike(0, buildUser(0));
}
public ConfigFluent.UsersNested editLastUser(){
int index = users.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last users. The list is empty.");
return setNewUserLike(index, buildUser(index));
}
public ConfigFluent.UsersNested editMatchingUser(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends NamedClusterFluentImpl> implements ConfigFluent.ClustersNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedClusterBuilder builder;
private final int index;
ClustersNestedImpl(int index,NamedCluster item){
this.index = index;
this.builder = new NamedClusterBuilder(this, item);
}
ClustersNestedImpl(){
this.index = -1;
this.builder = new NamedClusterBuilder(this);
}
public N and(){
return (N) ConfigFluentImpl.this.setToClusters(index, builder.build());
}
public N endCluster(){
return and();
}
}
public class ContextsNestedImpl extends NamedContextFluentImpl> implements ConfigFluent.ContextsNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedContextBuilder builder;
private final int index;
ContextsNestedImpl(int index,NamedContext item){
this.index = index;
this.builder = new NamedContextBuilder(this, item);
}
ContextsNestedImpl(){
this.index = -1;
this.builder = new NamedContextBuilder(this);
}
public N and(){
return (N) ConfigFluentImpl.this.setToContexts(index, builder.build());
}
public N endContext(){
return and();
}
}
public class ExtensionsNestedImpl extends NamedExtensionFluentImpl> implements ConfigFluent.ExtensionsNested,io.alauda.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) ConfigFluentImpl.this.setToExtensions(index, builder.build());
}
public N endExtension(){
return and();
}
}
public class PreferencesNestedImpl extends PreferencesFluentImpl> implements ConfigFluent.PreferencesNested,io.alauda.kubernetes.api.builder.Nested{
private final PreferencesBuilder builder;
PreferencesNestedImpl(Preferences item){
this.builder = new PreferencesBuilder(this, item);
}
PreferencesNestedImpl(){
this.builder = new PreferencesBuilder(this);
}
public N and(){
return (N) ConfigFluentImpl.this.withPreferences(builder.build());
}
public N endPreferences(){
return and();
}
}
public class UsersNestedImpl extends NamedAuthInfoFluentImpl> implements ConfigFluent.UsersNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedAuthInfoBuilder builder;
private final int index;
UsersNestedImpl(int index,NamedAuthInfo item){
this.index = index;
this.builder = new NamedAuthInfoBuilder(this, item);
}
UsersNestedImpl(){
this.index = -1;
this.builder = new NamedAuthInfoBuilder(this);
}
public N and(){
return (N) ConfigFluentImpl.this.setToUsers(index, builder.build());
}
public N endUser(){
return and();
}
}
}