All Downloads are FREE. Search and download functionalities are using the official Maven repository.

annotations.io.alauda.devops.api.model.ClusterRoleFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
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 ClusterRoleFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ClusterRoleFluent{

    private String apiVersion;
    private String kind;
    private ObjectMetaBuilder metadata;
    private List rules =  new ArrayList();

    public ClusterRoleFluentImpl(){
    }
    public ClusterRoleFluentImpl(ClusterRole instance){
            this.withApiVersion(instance.getApiVersion()); 
            this.withKind(instance.getKind()); 
            this.withMetadata(instance.getMetadata()); 
            this.withRules(instance.getRules()); 
    }

    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;
    }

    
/**
 * 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 ClusterRoleFluent.MetadataNested withNewMetadata(){
            return new MetadataNestedImpl();
    }

    public ClusterRoleFluent.MetadataNested withNewMetadataLike(ObjectMeta item){
            return new MetadataNestedImpl(item);
    }

    public ClusterRoleFluent.MetadataNested editMetadata(){
            return withNewMetadataLike(getMetadata());
    }

    public ClusterRoleFluent.MetadataNested editOrNewMetadata(){
            return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ObjectMetaBuilder().build());
    }

    public ClusterRoleFluent.MetadataNested editOrNewMetadataLike(ObjectMeta item){
            return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
    }

    public A addToRules(int index,PolicyRule item){
            PolicyRuleBuilder builder = new PolicyRuleBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.rules.add(index >= 0 ? index : rules.size(), builder); return (A)this;
    }

    public A setToRules(int index,PolicyRule item){
            PolicyRuleBuilder builder = new PolicyRuleBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= rules.size()) { rules.add(builder); } else { rules.set(index, builder);}
             return (A)this;
    }

    public A addToRules(PolicyRule... items){
            for (PolicyRule item : items) {PolicyRuleBuilder builder = new PolicyRuleBuilder(item);_visitables.add(builder);this.rules.add(builder);} return (A)this;
    }

    public A addAllToRules(Collection items){
            for (PolicyRule item : items) {PolicyRuleBuilder builder = new PolicyRuleBuilder(item);_visitables.add(builder);this.rules.add(builder);} return (A)this;
    }

    public A removeFromRules(PolicyRule... items){
            for (PolicyRule item : items) {PolicyRuleBuilder builder = new PolicyRuleBuilder(item);_visitables.remove(builder);this.rules.remove(builder);} return (A)this;
    }

    public A removeAllFromRules(Collection items){
            for (PolicyRule item : items) {PolicyRuleBuilder builder = new PolicyRuleBuilder(item);_visitables.remove(builder);this.rules.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildRules instead.
 */
@Deprecated public List getRules(){
            return build(rules);
    }

    public List buildRules(){
            return build(rules);
    }

    public PolicyRule buildRule(int index){
            return this.rules.get(index).build();
    }

    public PolicyRule buildFirstRule(){
            return this.rules.get(0).build();
    }

    public PolicyRule buildLastRule(){
            return this.rules.get(rules.size() - 1).build();
    }

    public PolicyRule buildMatchingRule(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (PolicyRuleBuilder item: rules) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withRules(List rules){
            _visitables.removeAll(this.rules);
            this.rules.clear();
            if (rules != null) {for (PolicyRule item : rules){this.addToRules(item);}} return (A) this;
    }

    public A withRules(PolicyRule... rules){
            this.rules.clear(); if (rules != null) {for (PolicyRule item :rules){ this.addToRules(item);}} return (A) this;
    }

    public Boolean hasRules(){
            return rules!= null && !rules.isEmpty();
    }

    public ClusterRoleFluent.RulesNested addNewRule(){
            return new RulesNestedImpl();
    }

    public ClusterRoleFluent.RulesNested addNewRuleLike(PolicyRule item){
            return new RulesNestedImpl(-1, item);
    }

    public ClusterRoleFluent.RulesNested setNewRuleLike(int index,PolicyRule item){
            return new RulesNestedImpl(index, item);
    }

    public ClusterRoleFluent.RulesNested editRule(int index){
            if (rules.size() <= index) throw new RuntimeException("Can't edit rules. Index exceeds size.");
            return setNewRuleLike(index, buildRule(index));
    }

    public ClusterRoleFluent.RulesNested editFirstRule(){
            if (rules.size() == 0) throw new RuntimeException("Can't edit first rules. The list is empty.");
            return setNewRuleLike(0, buildRule(0));
    }

    public ClusterRoleFluent.RulesNested editLastRule(){
            int index = rules.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last rules. The list is empty.");
            return setNewRuleLike(index, buildRule(index));
    }

    public ClusterRoleFluent.RulesNested editMatchingRule(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends ObjectMetaFluentImpl> implements ClusterRoleFluent.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) ClusterRoleFluentImpl.this.withMetadata(builder.build());
    }
    public N endMetadata(){
            return and();
    }

}
    public class RulesNestedImpl extends PolicyRuleFluentImpl> implements ClusterRoleFluent.RulesNested,io.alauda.kubernetes.api.builder.Nested{

            private final PolicyRuleBuilder builder;
        private final int index;
    
            RulesNestedImpl(int index,PolicyRule item){
                    this.index = index;
                    this.builder = new PolicyRuleBuilder(this, item);
            }
            RulesNestedImpl(){
                    this.index = -1;
                    this.builder = new PolicyRuleBuilder(this);
            }
    
    public N and(){
            return (N) ClusterRoleFluentImpl.this.setToRules(index, builder.build());
    }
    public N endRule(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy