io.alauda.kubernetes.api.model.authorization.SubjectAccessReviewSpecFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model.authorization;
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.util.LinkedHashMap;
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;
import java.util.Map;
public class SubjectAccessReviewSpecFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements SubjectAccessReviewSpecFluent{
private Map> extra = new LinkedHashMap>();
private List groups = new ArrayList();
private NonResourceAttributesBuilder nonResourceAttributes;
private ResourceAttributesBuilder resourceAttributes;
private String user;
public SubjectAccessReviewSpecFluentImpl(){
}
public SubjectAccessReviewSpecFluentImpl(SubjectAccessReviewSpec instance){
this.withExtra(instance.getExtra());
this.withGroups(instance.getGroups());
this.withNonResourceAttributes(instance.getNonResourceAttributes());
this.withResourceAttributes(instance.getResourceAttributes());
this.withUser(instance.getUser());
}
public A addToExtra(String key,ArrayList value){
if(key != null && value != null) {this.extra.put(key, value);} return (A)this;
}
public A addToExtra(Map> map){
if(map != null) { this.extra.putAll(map);} return (A)this;
}
public A removeFromExtra(String key){
if(key != null) {this.extra.remove(key);} return (A)this;
}
public A removeFromExtra(Map> map){
if(map != null) { for(Object key : map.keySet()) {this.extra.remove(key);}} return (A)this;
}
public Map> getExtra(){
return this.extra;
}
public A withExtra(Map> extra){
this.extra.clear();
if (extra != null) {this.extra.putAll(extra);} return (A) this;
}
public Boolean hasExtra(){
return this.extra!=null;
}
public A addToGroups(int index,String item){
this.groups.add(index, item); return (A)this;
}
public A setToGroups(int index,String item){
this.groups.set(index, item); return (A)this;
}
public A addToGroups(String... items){
for (String item : items) {this.groups.add(item);} return (A)this;
}
public A addAllToGroups(Collection items){
for (String item : items) {this.groups.add(item);} return (A)this;
}
public A removeFromGroups(String... items){
for (String item : items) {this.groups.remove(item);} return (A)this;
}
public A removeAllFromGroups(Collection items){
for (String item : items) {this.groups.remove(item);} return (A)this;
}
public List getGroups(){
return this.groups;
}
public String getGroup(int index){
return this.groups.get(index);
}
public String getFirstGroup(){
return this.groups.get(0);
}
public String getLastGroup(){
return this.groups.get(groups.size() - 1);
}
public String getMatchingGroup(io.alauda.kubernetes.api.builder.Predicate predicate){
for (String item: groups) { if(predicate.apply(item)){return item;} } return null;
}
public A withGroups(List groups){
this.groups.clear();
if (groups != null) {for (String item : groups){this.addToGroups(item);}} return (A) this;
}
public A withGroups(String... groups){
this.groups.clear(); if (groups != null) {for (String item :groups){ this.addToGroups(item);}} return (A) this;
}
public Boolean hasGroups(){
return groups!= null && !groups.isEmpty();
}
/**
* This method has been deprecated, please use method buildNonResourceAttributes instead.
*/
@Deprecated public NonResourceAttributes getNonResourceAttributes(){
return this.nonResourceAttributes!=null?this.nonResourceAttributes.build():null;
}
public NonResourceAttributes buildNonResourceAttributes(){
return this.nonResourceAttributes!=null?this.nonResourceAttributes.build():null;
}
public A withNonResourceAttributes(NonResourceAttributes nonResourceAttributes){
_visitables.remove(this.nonResourceAttributes);
if (nonResourceAttributes!=null){ this.nonResourceAttributes= new NonResourceAttributesBuilder(nonResourceAttributes); _visitables.add(this.nonResourceAttributes);} return (A) this;
}
public Boolean hasNonResourceAttributes(){
return this.nonResourceAttributes!=null;
}
public SubjectAccessReviewSpecFluent.NonResourceAttributesNested withNewNonResourceAttributes(){
return new NonResourceAttributesNestedImpl();
}
public SubjectAccessReviewSpecFluent.NonResourceAttributesNested withNewNonResourceAttributesLike(NonResourceAttributes item){
return new NonResourceAttributesNestedImpl(item);
}
public SubjectAccessReviewSpecFluent.NonResourceAttributesNested editNonResourceAttributes(){
return withNewNonResourceAttributesLike(getNonResourceAttributes());
}
public SubjectAccessReviewSpecFluent.NonResourceAttributesNested editOrNewNonResourceAttributes(){
return withNewNonResourceAttributesLike(getNonResourceAttributes() != null ? getNonResourceAttributes(): new NonResourceAttributesBuilder().build());
}
public SubjectAccessReviewSpecFluent.NonResourceAttributesNested editOrNewNonResourceAttributesLike(NonResourceAttributes item){
return withNewNonResourceAttributesLike(getNonResourceAttributes() != null ? getNonResourceAttributes(): item);
}
public A withNewNonResourceAttributes(String path,String verb){
return (A)withNonResourceAttributes(new NonResourceAttributes(path, verb));
}
/**
* This method has been deprecated, please use method buildResourceAttributes instead.
*/
@Deprecated public ResourceAttributes getResourceAttributes(){
return this.resourceAttributes!=null?this.resourceAttributes.build():null;
}
public ResourceAttributes buildResourceAttributes(){
return this.resourceAttributes!=null?this.resourceAttributes.build():null;
}
public A withResourceAttributes(ResourceAttributes resourceAttributes){
_visitables.remove(this.resourceAttributes);
if (resourceAttributes!=null){ this.resourceAttributes= new ResourceAttributesBuilder(resourceAttributes); _visitables.add(this.resourceAttributes);} return (A) this;
}
public Boolean hasResourceAttributes(){
return this.resourceAttributes!=null;
}
public SubjectAccessReviewSpecFluent.ResourceAttributesNested withNewResourceAttributes(){
return new ResourceAttributesNestedImpl();
}
public SubjectAccessReviewSpecFluent.ResourceAttributesNested withNewResourceAttributesLike(ResourceAttributes item){
return new ResourceAttributesNestedImpl(item);
}
public SubjectAccessReviewSpecFluent.ResourceAttributesNested editResourceAttributes(){
return withNewResourceAttributesLike(getResourceAttributes());
}
public SubjectAccessReviewSpecFluent.ResourceAttributesNested editOrNewResourceAttributes(){
return withNewResourceAttributesLike(getResourceAttributes() != null ? getResourceAttributes(): new ResourceAttributesBuilder().build());
}
public SubjectAccessReviewSpecFluent.ResourceAttributesNested editOrNewResourceAttributesLike(ResourceAttributes item){
return withNewResourceAttributesLike(getResourceAttributes() != null ? getResourceAttributes(): item);
}
public String getUser(){
return this.user;
}
public A withUser(String user){
this.user=user; return (A) this;
}
public Boolean hasUser(){
return this.user!=null;
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SubjectAccessReviewSpecFluentImpl that = (SubjectAccessReviewSpecFluentImpl) o;
if (extra != null ? !extra.equals(that.extra) :that.extra != null) return false;
if (groups != null ? !groups.equals(that.groups) :that.groups != null) return false;
if (nonResourceAttributes != null ? !nonResourceAttributes.equals(that.nonResourceAttributes) :that.nonResourceAttributes != null) return false;
if (resourceAttributes != null ? !resourceAttributes.equals(that.resourceAttributes) :that.resourceAttributes != null) return false;
if (user != null ? !user.equals(that.user) :that.user != null) return false;
return true;
}
public class NonResourceAttributesNestedImpl extends NonResourceAttributesFluentImpl> implements SubjectAccessReviewSpecFluent.NonResourceAttributesNested,io.alauda.kubernetes.api.builder.Nested{
private final NonResourceAttributesBuilder builder;
NonResourceAttributesNestedImpl(NonResourceAttributes item){
this.builder = new NonResourceAttributesBuilder(this, item);
}
NonResourceAttributesNestedImpl(){
this.builder = new NonResourceAttributesBuilder(this);
}
public N and(){
return (N) SubjectAccessReviewSpecFluentImpl.this.withNonResourceAttributes(builder.build());
}
public N endNonResourceAttributes(){
return and();
}
}
public class ResourceAttributesNestedImpl extends ResourceAttributesFluentImpl> implements SubjectAccessReviewSpecFluent.ResourceAttributesNested,io.alauda.kubernetes.api.builder.Nested{
private final ResourceAttributesBuilder builder;
ResourceAttributesNestedImpl(ResourceAttributes item){
this.builder = new ResourceAttributesBuilder(this, item);
}
ResourceAttributesNestedImpl(){
this.builder = new ResourceAttributesBuilder(this);
}
public N and(){
return (N) SubjectAccessReviewSpecFluentImpl.this.withResourceAttributes(builder.build());
}
public N endResourceAttributes(){
return and();
}
}
}