annotations.io.alauda.devops.api.model.ClusterPolicyFluentImpl Maven / Gradle / Ivy
package io.alauda.devops.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.alauda.kubernetes.api.model.validators.CheckObjectMeta;
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 io.alauda.kubernetes.api.model.ObjectMeta;
import io.alauda.kubernetes.api.model.ObjectMetaFluentImpl;
import io.alauda.kubernetes.api.model.ObjectMetaBuilder;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;
public class ClusterPolicyFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ClusterPolicyFluent{
private String apiVersion;
private String kind;
private String lastModified;
private ObjectMetaBuilder metadata;
private List roles = new ArrayList();
public ClusterPolicyFluentImpl(){
}
public ClusterPolicyFluentImpl(ClusterPolicy instance){
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withLastModified(instance.getLastModified());
this.withMetadata(instance.getMetadata());
this.withRoles(instance.getRoles());
}
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 String getKind(){
return this.kind;
}
public A withKind(String kind){
this.kind=kind; return (A) this;
}
public Boolean hasKind(){
return this.kind!=null;
}
public String getLastModified(){
return this.lastModified;
}
public A withLastModified(String lastModified){
this.lastModified=lastModified; return (A) this;
}
public Boolean hasLastModified(){
return this.lastModified!=null;
}
/**
* This method has been deprecated, please use method buildMetadata instead.
*/
@Deprecated public ObjectMeta getMetadata(){
return this.metadata!=null?this.metadata.build():null;
}
public ObjectMeta buildMetadata(){
return this.metadata!=null?this.metadata.build():null;
}
public A withMetadata(ObjectMeta metadata){
_visitables.remove(this.metadata);
if (metadata!=null){ this.metadata= new ObjectMetaBuilder(metadata); _visitables.add(this.metadata);} return (A) this;
}
public Boolean hasMetadata(){
return this.metadata!=null;
}
public ClusterPolicyFluent.MetadataNested withNewMetadata(){
return new MetadataNestedImpl();
}
public ClusterPolicyFluent.MetadataNested withNewMetadataLike(ObjectMeta item){
return new MetadataNestedImpl(item);
}
public ClusterPolicyFluent.MetadataNested editMetadata(){
return withNewMetadataLike(getMetadata());
}
public ClusterPolicyFluent.MetadataNested editOrNewMetadata(){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ObjectMetaBuilder().build());
}
public ClusterPolicyFluent.MetadataNested editOrNewMetadataLike(ObjectMeta item){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
public A addToRoles(int index,NamedClusterRole item){
NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.roles.add(index >= 0 ? index : roles.size(), builder); return (A)this;
}
public A setToRoles(int index,NamedClusterRole item){
NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= roles.size()) { roles.add(builder); } else { roles.set(index, builder);}
return (A)this;
}
public A addToRoles(NamedClusterRole... items){
for (NamedClusterRole item : items) {NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);_visitables.add(builder);this.roles.add(builder);} return (A)this;
}
public A addAllToRoles(Collection items){
for (NamedClusterRole item : items) {NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);_visitables.add(builder);this.roles.add(builder);} return (A)this;
}
public A removeFromRoles(NamedClusterRole... items){
for (NamedClusterRole item : items) {NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);_visitables.remove(builder);this.roles.remove(builder);} return (A)this;
}
public A removeAllFromRoles(Collection items){
for (NamedClusterRole item : items) {NamedClusterRoleBuilder builder = new NamedClusterRoleBuilder(item);_visitables.remove(builder);this.roles.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildRoles instead.
*/
@Deprecated public List getRoles(){
return build(roles);
}
public List buildRoles(){
return build(roles);
}
public NamedClusterRole buildRole(int index){
return this.roles.get(index).build();
}
public NamedClusterRole buildFirstRole(){
return this.roles.get(0).build();
}
public NamedClusterRole buildLastRole(){
return this.roles.get(roles.size() - 1).build();
}
public NamedClusterRole buildMatchingRole(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedClusterRoleBuilder item: roles) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withRoles(List roles){
_visitables.removeAll(this.roles);
this.roles.clear();
if (roles != null) {for (NamedClusterRole item : roles){this.addToRoles(item);}} return (A) this;
}
public A withRoles(NamedClusterRole... roles){
this.roles.clear(); if (roles != null) {for (NamedClusterRole item :roles){ this.addToRoles(item);}} return (A) this;
}
public Boolean hasRoles(){
return roles!= null && !roles.isEmpty();
}
public ClusterPolicyFluent.RolesNested addNewRole(){
return new RolesNestedImpl();
}
public ClusterPolicyFluent.RolesNested addNewRoleLike(NamedClusterRole item){
return new RolesNestedImpl(-1, item);
}
public ClusterPolicyFluent.RolesNested setNewRoleLike(int index,NamedClusterRole item){
return new RolesNestedImpl(index, item);
}
public ClusterPolicyFluent.RolesNested editRole(int index){
if (roles.size() <= index) throw new RuntimeException("Can't edit roles. Index exceeds size.");
return setNewRoleLike(index, buildRole(index));
}
public ClusterPolicyFluent.RolesNested editFirstRole(){
if (roles.size() == 0) throw new RuntimeException("Can't edit first roles. The list is empty.");
return setNewRoleLike(0, buildRole(0));
}
public ClusterPolicyFluent.RolesNested editLastRole(){
int index = roles.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last roles. The list is empty.");
return setNewRoleLike(index, buildRole(index));
}
public ClusterPolicyFluent.RolesNested editMatchingRole(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends ObjectMetaFluentImpl> implements ClusterPolicyFluent.MetadataNested,io.alauda.kubernetes.api.builder.Nested{
private final ObjectMetaBuilder builder;
MetadataNestedImpl(ObjectMeta item){
this.builder = new ObjectMetaBuilder(this, item);
}
MetadataNestedImpl(){
this.builder = new ObjectMetaBuilder(this);
}
public N and(){
return (N) ClusterPolicyFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata(){
return and();
}
}
public class RolesNestedImpl extends NamedClusterRoleFluentImpl> implements ClusterPolicyFluent.RolesNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedClusterRoleBuilder builder;
private final int index;
RolesNestedImpl(int index,NamedClusterRole item){
this.index = index;
this.builder = new NamedClusterRoleBuilder(this, item);
}
RolesNestedImpl(){
this.index = -1;
this.builder = new NamedClusterRoleBuilder(this);
}
public N and(){
return (N) ClusterPolicyFluentImpl.this.setToRoles(index, builder.build());
}
public N endRole(){
return and();
}
}
}