io.alauda.devops.api.model.ScopeRestrictionFluentImpl Maven / Gradle / Ivy
package io.alauda.devops.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 ScopeRestrictionFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ScopeRestrictionFluent{
private ClusterRoleScopeRestrictionBuilder clusterRole;
private List literals = new ArrayList();
public ScopeRestrictionFluentImpl(){
}
public ScopeRestrictionFluentImpl(ScopeRestriction instance){
this.withClusterRole(instance.getClusterRole());
this.withLiterals(instance.getLiterals());
}
/**
* This method has been deprecated, please use method buildClusterRole instead.
*/
@Deprecated public ClusterRoleScopeRestriction getClusterRole(){
return this.clusterRole!=null?this.clusterRole.build():null;
}
public ClusterRoleScopeRestriction buildClusterRole(){
return this.clusterRole!=null?this.clusterRole.build():null;
}
public A withClusterRole(ClusterRoleScopeRestriction clusterRole){
_visitables.remove(this.clusterRole);
if (clusterRole!=null){ this.clusterRole= new ClusterRoleScopeRestrictionBuilder(clusterRole); _visitables.add(this.clusterRole);} return (A) this;
}
public Boolean hasClusterRole(){
return this.clusterRole!=null;
}
public ScopeRestrictionFluent.ClusterRoleNested withNewClusterRole(){
return new ClusterRoleNestedImpl();
}
public ScopeRestrictionFluent.ClusterRoleNested withNewClusterRoleLike(ClusterRoleScopeRestriction item){
return new ClusterRoleNestedImpl(item);
}
public ScopeRestrictionFluent.ClusterRoleNested editClusterRole(){
return withNewClusterRoleLike(getClusterRole());
}
public ScopeRestrictionFluent.ClusterRoleNested editOrNewClusterRole(){
return withNewClusterRoleLike(getClusterRole() != null ? getClusterRole(): new ClusterRoleScopeRestrictionBuilder().build());
}
public ScopeRestrictionFluent.ClusterRoleNested editOrNewClusterRoleLike(ClusterRoleScopeRestriction item){
return withNewClusterRoleLike(getClusterRole() != null ? getClusterRole(): item);
}
public A addToLiterals(int index,String item){
this.literals.add(index, item); return (A)this;
}
public A setToLiterals(int index,String item){
this.literals.set(index, item); return (A)this;
}
public A addToLiterals(String... items){
for (String item : items) {this.literals.add(item);} return (A)this;
}
public A addAllToLiterals(Collection items){
for (String item : items) {this.literals.add(item);} return (A)this;
}
public A removeFromLiterals(String... items){
for (String item : items) {this.literals.remove(item);} return (A)this;
}
public A removeAllFromLiterals(Collection items){
for (String item : items) {this.literals.remove(item);} return (A)this;
}
public List getLiterals(){
return this.literals;
}
public String getLiteral(int index){
return this.literals.get(index);
}
public String getFirstLiteral(){
return this.literals.get(0);
}
public String getLastLiteral(){
return this.literals.get(literals.size() - 1);
}
public String getMatchingLiteral(io.alauda.kubernetes.api.builder.Predicate predicate){
for (String item: literals) { if(predicate.apply(item)){return item;} } return null;
}
public A withLiterals(List literals){
this.literals.clear();
if (literals != null) {for (String item : literals){this.addToLiterals(item);}} return (A) this;
}
public A withLiterals(String... literals){
this.literals.clear(); if (literals != null) {for (String item :literals){ this.addToLiterals(item);}} return (A) this;
}
public Boolean hasLiterals(){
return literals!= null && !literals.isEmpty();
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
ScopeRestrictionFluentImpl that = (ScopeRestrictionFluentImpl) o;
if (clusterRole != null ? !clusterRole.equals(that.clusterRole) :that.clusterRole != null) return false;
if (literals != null ? !literals.equals(that.literals) :that.literals != null) return false;
return true;
}
public class ClusterRoleNestedImpl extends ClusterRoleScopeRestrictionFluentImpl> implements ScopeRestrictionFluent.ClusterRoleNested,io.alauda.kubernetes.api.builder.Nested{
private final ClusterRoleScopeRestrictionBuilder builder;
ClusterRoleNestedImpl(ClusterRoleScopeRestriction item){
this.builder = new ClusterRoleScopeRestrictionBuilder(this, item);
}
ClusterRoleNestedImpl(){
this.builder = new ClusterRoleScopeRestrictionBuilder(this);
}
public N and(){
return (N) ScopeRestrictionFluentImpl.this.withClusterRole(builder.build());
}
public N endClusterRole(){
return and();
}
}
}