io.alauda.kubernetes.api.model.PodSecurityContextFluentImpl 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.lang.Long;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
public class PodSecurityContextFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PodSecurityContextFluent{
private Long fsGroup;
private Boolean runAsNonRoot;
private Long runAsUser;
private SELinuxOptionsBuilder seLinuxOptions;
private List supplementalGroups = new ArrayList();
public PodSecurityContextFluentImpl(){
}
public PodSecurityContextFluentImpl(PodSecurityContext instance){
this.withFsGroup(instance.getFsGroup());
this.withRunAsNonRoot(instance.getRunAsNonRoot());
this.withRunAsUser(instance.getRunAsUser());
this.withSeLinuxOptions(instance.getSeLinuxOptions());
this.withSupplementalGroups(instance.getSupplementalGroups());
}
public Long getFsGroup(){
return this.fsGroup;
}
public A withFsGroup(Long fsGroup){
this.fsGroup=fsGroup; return (A) this;
}
public Boolean hasFsGroup(){
return this.fsGroup!=null;
}
public Boolean isRunAsNonRoot(){
return this.runAsNonRoot;
}
public A withRunAsNonRoot(Boolean runAsNonRoot){
this.runAsNonRoot=runAsNonRoot; return (A) this;
}
public Boolean hasRunAsNonRoot(){
return this.runAsNonRoot!=null;
}
public Long getRunAsUser(){
return this.runAsUser;
}
public A withRunAsUser(Long runAsUser){
this.runAsUser=runAsUser; return (A) this;
}
public Boolean hasRunAsUser(){
return this.runAsUser!=null;
}
/**
* This method has been deprecated, please use method buildSeLinuxOptions instead.
*/
@Deprecated public SELinuxOptions getSeLinuxOptions(){
return this.seLinuxOptions!=null?this.seLinuxOptions.build():null;
}
public SELinuxOptions buildSeLinuxOptions(){
return this.seLinuxOptions!=null?this.seLinuxOptions.build():null;
}
public A withSeLinuxOptions(SELinuxOptions seLinuxOptions){
_visitables.remove(this.seLinuxOptions);
if (seLinuxOptions!=null){ this.seLinuxOptions= new SELinuxOptionsBuilder(seLinuxOptions); _visitables.add(this.seLinuxOptions);} return (A) this;
}
public Boolean hasSeLinuxOptions(){
return this.seLinuxOptions!=null;
}
public PodSecurityContextFluent.SeLinuxOptionsNested withNewSeLinuxOptions(){
return new SeLinuxOptionsNestedImpl();
}
public PodSecurityContextFluent.SeLinuxOptionsNested withNewSeLinuxOptionsLike(SELinuxOptions item){
return new SeLinuxOptionsNestedImpl(item);
}
public PodSecurityContextFluent.SeLinuxOptionsNested editSeLinuxOptions(){
return withNewSeLinuxOptionsLike(getSeLinuxOptions());
}
public PodSecurityContextFluent.SeLinuxOptionsNested editOrNewSeLinuxOptions(){
return withNewSeLinuxOptionsLike(getSeLinuxOptions() != null ? getSeLinuxOptions(): new SELinuxOptionsBuilder().build());
}
public PodSecurityContextFluent.SeLinuxOptionsNested editOrNewSeLinuxOptionsLike(SELinuxOptions item){
return withNewSeLinuxOptionsLike(getSeLinuxOptions() != null ? getSeLinuxOptions(): item);
}
public A withNewSeLinuxOptions(String level,String role,String type,String user){
return (A)withSeLinuxOptions(new SELinuxOptions(level, role, type, user));
}
public A addToSupplementalGroups(int index,Long item){
this.supplementalGroups.add(index, item); return (A)this;
}
public A setToSupplementalGroups(int index,Long item){
this.supplementalGroups.set(index, item); return (A)this;
}
public A addToSupplementalGroups(Long... items){
for (Long item : items) {this.supplementalGroups.add(item);} return (A)this;
}
public A addAllToSupplementalGroups(Collection items){
for (Long item : items) {this.supplementalGroups.add(item);} return (A)this;
}
public A removeFromSupplementalGroups(Long... items){
for (Long item : items) {this.supplementalGroups.remove(item);} return (A)this;
}
public A removeAllFromSupplementalGroups(Collection items){
for (Long item : items) {this.supplementalGroups.remove(item);} return (A)this;
}
public List getSupplementalGroups(){
return this.supplementalGroups;
}
public Long getSupplementalGroup(int index){
return this.supplementalGroups.get(index);
}
public Long getFirstSupplementalGroup(){
return this.supplementalGroups.get(0);
}
public Long getLastSupplementalGroup(){
return this.supplementalGroups.get(supplementalGroups.size() - 1);
}
public Long getMatchingSupplementalGroup(io.alauda.kubernetes.api.builder.Predicate predicate){
for (Long item: supplementalGroups) { if(predicate.apply(item)){return item;} } return null;
}
public A withSupplementalGroups(List supplementalGroups){
this.supplementalGroups.clear();
if (supplementalGroups != null) {for (Long item : supplementalGroups){this.addToSupplementalGroups(item);}} return (A) this;
}
public A withSupplementalGroups(Long... supplementalGroups){
this.supplementalGroups.clear(); if (supplementalGroups != null) {for (Long item :supplementalGroups){ this.addToSupplementalGroups(item);}} return (A) this;
}
public Boolean hasSupplementalGroups(){
return supplementalGroups!= null && !supplementalGroups.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;
PodSecurityContextFluentImpl that = (PodSecurityContextFluentImpl) o;
if (fsGroup != null ? !fsGroup.equals(that.fsGroup) :that.fsGroup != null) return false;
if (runAsNonRoot != null ? !runAsNonRoot.equals(that.runAsNonRoot) :that.runAsNonRoot != null) return false;
if (runAsUser != null ? !runAsUser.equals(that.runAsUser) :that.runAsUser != null) return false;
if (seLinuxOptions != null ? !seLinuxOptions.equals(that.seLinuxOptions) :that.seLinuxOptions != null) return false;
if (supplementalGroups != null ? !supplementalGroups.equals(that.supplementalGroups) :that.supplementalGroups != null) return false;
return true;
}
public class SeLinuxOptionsNestedImpl extends SELinuxOptionsFluentImpl> implements PodSecurityContextFluent.SeLinuxOptionsNested,io.alauda.kubernetes.api.builder.Nested{
private final SELinuxOptionsBuilder builder;
SeLinuxOptionsNestedImpl(SELinuxOptions item){
this.builder = new SELinuxOptionsBuilder(this, item);
}
SeLinuxOptionsNestedImpl(){
this.builder = new SELinuxOptionsBuilder(this);
}
public N and(){
return (N) PodSecurityContextFluentImpl.this.withSeLinuxOptions(builder.build());
}
public N endSeLinuxOptions(){
return and();
}
}
}