annotations.io.alauda.kubernetes.api.model.ClusterFluentImpl 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 io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class ClusterFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ClusterFluent{
private String certificateAuthority;
private String certificateAuthorityData;
private List extensions = new ArrayList();
private Boolean insecureSkipTlsVerify;
private String server;
public ClusterFluentImpl(){
}
public ClusterFluentImpl(Cluster instance){
this.withCertificateAuthority(instance.getCertificateAuthority());
this.withCertificateAuthorityData(instance.getCertificateAuthorityData());
this.withExtensions(instance.getExtensions());
this.withInsecureSkipTlsVerify(instance.getInsecureSkipTlsVerify());
this.withServer(instance.getServer());
}
public String getCertificateAuthority(){
return this.certificateAuthority;
}
public A withCertificateAuthority(String certificateAuthority){
this.certificateAuthority=certificateAuthority; return (A) this;
}
public Boolean hasCertificateAuthority(){
return this.certificateAuthority!=null;
}
public String getCertificateAuthorityData(){
return this.certificateAuthorityData;
}
public A withCertificateAuthorityData(String certificateAuthorityData){
this.certificateAuthorityData=certificateAuthorityData; return (A) this;
}
public Boolean hasCertificateAuthorityData(){
return this.certificateAuthorityData!=null;
}
public A addToExtensions(int index,NamedExtension item){
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(index >= 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 ClusterFluent.ExtensionsNested addNewExtension(){
return new ExtensionsNestedImpl();
}
public ClusterFluent.ExtensionsNested addNewExtensionLike(NamedExtension item){
return new ExtensionsNestedImpl(-1, item);
}
public ClusterFluent.ExtensionsNested setNewExtensionLike(int index,NamedExtension item){
return new ExtensionsNestedImpl(index, item);
}
public ClusterFluent.ExtensionsNested editExtension(int index){
if (extensions.size() <= index) throw new RuntimeException("Can't edit extensions. Index exceeds size.");
return setNewExtensionLike(index, buildExtension(index));
}
public ClusterFluent.ExtensionsNested editFirstExtension(){
if (extensions.size() == 0) throw new RuntimeException("Can't edit first extensions. The list is empty.");
return setNewExtensionLike(0, buildExtension(0));
}
public ClusterFluent.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 ClusterFluent.ExtensionsNested editMatchingExtension(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends NamedExtensionFluentImpl> implements ClusterFluent.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) ClusterFluentImpl.this.setToExtensions(index, builder.build());
}
public N endExtension(){
return and();
}
}
}