io.alauda.devops.api.model.PolicyBindingFluentImpl 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 io.alauda.kubernetes.api.model.ObjectReference;
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.ObjectReferenceFluentImpl;
import io.alauda.kubernetes.api.model.ObjectMetaBuilder;
import javax.validation.Valid;
import io.alauda.kubernetes.api.model.ObjectReferenceBuilder;
import java.util.Collection;
import java.lang.Object;
public class PolicyBindingFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PolicyBindingFluent{
private String apiVersion;
private String kind;
private String lastModified;
private ObjectMetaBuilder metadata;
private ObjectReferenceBuilder policyRef;
private List roleBindings = new ArrayList();
public PolicyBindingFluentImpl(){
}
public PolicyBindingFluentImpl(PolicyBinding instance){
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withLastModified(instance.getLastModified());
this.withMetadata(instance.getMetadata());
this.withPolicyRef(instance.getPolicyRef());
this.withRoleBindings(instance.getRoleBindings());
}
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 PolicyBindingFluent.MetadataNested withNewMetadata(){
return new MetadataNestedImpl();
}
public PolicyBindingFluent.MetadataNested withNewMetadataLike(ObjectMeta item){
return new MetadataNestedImpl(item);
}
public PolicyBindingFluent.MetadataNested editMetadata(){
return withNewMetadataLike(getMetadata());
}
public PolicyBindingFluent.MetadataNested editOrNewMetadata(){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ObjectMetaBuilder().build());
}
public PolicyBindingFluent.MetadataNested editOrNewMetadataLike(ObjectMeta item){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
/**
* This method has been deprecated, please use method buildPolicyRef instead.
*/
@Deprecated public ObjectReference getPolicyRef(){
return this.policyRef!=null?this.policyRef.build():null;
}
public ObjectReference buildPolicyRef(){
return this.policyRef!=null?this.policyRef.build():null;
}
public A withPolicyRef(ObjectReference policyRef){
_visitables.remove(this.policyRef);
if (policyRef!=null){ this.policyRef= new ObjectReferenceBuilder(policyRef); _visitables.add(this.policyRef);} return (A) this;
}
public Boolean hasPolicyRef(){
return this.policyRef!=null;
}
public PolicyBindingFluent.PolicyRefNested withNewPolicyRef(){
return new PolicyRefNestedImpl();
}
public PolicyBindingFluent.PolicyRefNested withNewPolicyRefLike(ObjectReference item){
return new PolicyRefNestedImpl(item);
}
public PolicyBindingFluent.PolicyRefNested editPolicyRef(){
return withNewPolicyRefLike(getPolicyRef());
}
public PolicyBindingFluent.PolicyRefNested editOrNewPolicyRef(){
return withNewPolicyRefLike(getPolicyRef() != null ? getPolicyRef(): new ObjectReferenceBuilder().build());
}
public PolicyBindingFluent.PolicyRefNested editOrNewPolicyRefLike(ObjectReference item){
return withNewPolicyRefLike(getPolicyRef() != null ? getPolicyRef(): item);
}
public A addToRoleBindings(int index,NamedRoleBinding item){
NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.roleBindings.add(index >= 0 ? index : roleBindings.size(), builder); return (A)this;
}
public A setToRoleBindings(int index,NamedRoleBinding item){
NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= roleBindings.size()) { roleBindings.add(builder); } else { roleBindings.set(index, builder);}
return (A)this;
}
public A addToRoleBindings(NamedRoleBinding... items){
for (NamedRoleBinding item : items) {NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);_visitables.add(builder);this.roleBindings.add(builder);} return (A)this;
}
public A addAllToRoleBindings(Collection items){
for (NamedRoleBinding item : items) {NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);_visitables.add(builder);this.roleBindings.add(builder);} return (A)this;
}
public A removeFromRoleBindings(NamedRoleBinding... items){
for (NamedRoleBinding item : items) {NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);_visitables.remove(builder);this.roleBindings.remove(builder);} return (A)this;
}
public A removeAllFromRoleBindings(Collection items){
for (NamedRoleBinding item : items) {NamedRoleBindingBuilder builder = new NamedRoleBindingBuilder(item);_visitables.remove(builder);this.roleBindings.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildRoleBindings instead.
*/
@Deprecated public List getRoleBindings(){
return build(roleBindings);
}
public List buildRoleBindings(){
return build(roleBindings);
}
public NamedRoleBinding buildRoleBinding(int index){
return this.roleBindings.get(index).build();
}
public NamedRoleBinding buildFirstRoleBinding(){
return this.roleBindings.get(0).build();
}
public NamedRoleBinding buildLastRoleBinding(){
return this.roleBindings.get(roleBindings.size() - 1).build();
}
public NamedRoleBinding buildMatchingRoleBinding(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedRoleBindingBuilder item: roleBindings) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withRoleBindings(List roleBindings){
_visitables.removeAll(this.roleBindings);
this.roleBindings.clear();
if (roleBindings != null) {for (NamedRoleBinding item : roleBindings){this.addToRoleBindings(item);}} return (A) this;
}
public A withRoleBindings(NamedRoleBinding... roleBindings){
this.roleBindings.clear(); if (roleBindings != null) {for (NamedRoleBinding item :roleBindings){ this.addToRoleBindings(item);}} return (A) this;
}
public Boolean hasRoleBindings(){
return roleBindings!= null && !roleBindings.isEmpty();
}
public PolicyBindingFluent.RoleBindingsNested addNewRoleBinding(){
return new RoleBindingsNestedImpl();
}
public PolicyBindingFluent.RoleBindingsNested addNewRoleBindingLike(NamedRoleBinding item){
return new RoleBindingsNestedImpl(-1, item);
}
public PolicyBindingFluent.RoleBindingsNested setNewRoleBindingLike(int index,NamedRoleBinding item){
return new RoleBindingsNestedImpl(index, item);
}
public PolicyBindingFluent.RoleBindingsNested editRoleBinding(int index){
if (roleBindings.size() <= index) throw new RuntimeException("Can't edit roleBindings. Index exceeds size.");
return setNewRoleBindingLike(index, buildRoleBinding(index));
}
public PolicyBindingFluent.RoleBindingsNested editFirstRoleBinding(){
if (roleBindings.size() == 0) throw new RuntimeException("Can't edit first roleBindings. The list is empty.");
return setNewRoleBindingLike(0, buildRoleBinding(0));
}
public PolicyBindingFluent.RoleBindingsNested editLastRoleBinding(){
int index = roleBindings.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last roleBindings. The list is empty.");
return setNewRoleBindingLike(index, buildRoleBinding(index));
}
public PolicyBindingFluent.RoleBindingsNested editMatchingRoleBinding(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends ObjectMetaFluentImpl> implements PolicyBindingFluent.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) PolicyBindingFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata(){
return and();
}
}
public class PolicyRefNestedImpl extends ObjectReferenceFluentImpl> implements PolicyBindingFluent.PolicyRefNested,io.alauda.kubernetes.api.builder.Nested{
private final ObjectReferenceBuilder builder;
PolicyRefNestedImpl(ObjectReference item){
this.builder = new ObjectReferenceBuilder(this, item);
}
PolicyRefNestedImpl(){
this.builder = new ObjectReferenceBuilder(this);
}
public N and(){
return (N) PolicyBindingFluentImpl.this.withPolicyRef(builder.build());
}
public N endPolicyRef(){
return and();
}
}
public class RoleBindingsNestedImpl extends NamedRoleBindingFluentImpl> implements PolicyBindingFluent.RoleBindingsNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedRoleBindingBuilder builder;
private final int index;
RoleBindingsNestedImpl(int index,NamedRoleBinding item){
this.index = index;
this.builder = new NamedRoleBindingBuilder(this, item);
}
RoleBindingsNestedImpl(){
this.index = -1;
this.builder = new NamedRoleBindingBuilder(this);
}
public N and(){
return (N) PolicyBindingFluentImpl.this.setToRoleBindings(index, builder.build());
}
public N endRoleBinding(){
return and();
}
}
}