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

io.strimzi.api.kafka.model.KafkaUserAuthorizationSimpleFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.45.0
Show newest version
package io.strimzi.api.kafka.model;

import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.fabric8.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class KafkaUserAuthorizationSimpleFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements KafkaUserAuthorizationSimpleFluent{

    private List acls;

    public KafkaUserAuthorizationSimpleFluentImpl(){
    }
    public KafkaUserAuthorizationSimpleFluentImpl(KafkaUserAuthorizationSimple instance){
            this.withAcls(instance.getAcls());

    }

    public A addToAcls(int index,AclRule item){
            if (this.acls == null) {this.acls = new ArrayList();}
            AclRuleBuilder builder = new AclRuleBuilder(item);_visitables.get("acls").add(index >= 0 ? index : _visitables.get("acls").size(), builder);this.acls.add(index >= 0 ? index : acls.size(), builder); return (A)this;
    }

    public A setToAcls(int index,AclRule item){
            if (this.acls == null) {this.acls = new ArrayList();}
            AclRuleBuilder builder = new AclRuleBuilder(item);
            if (index < 0 || index >= _visitables.get("acls").size()) { _visitables.get("acls").add(builder); } else { _visitables.get("acls").set(index, builder);}
            if (index < 0 || index >= acls.size()) { acls.add(builder); } else { acls.set(index, builder);}
             return (A)this;
    }

    public A addToAcls(AclRule... items){
            if (this.acls == null) {this.acls = new ArrayList();}
            for (AclRule item : items) {AclRuleBuilder builder = new AclRuleBuilder(item);_visitables.get("acls").add(builder);this.acls.add(builder);} return (A)this;
    }

    public A addAllToAcls(Collection items){
            if (this.acls == null) {this.acls = new ArrayList();}
            for (AclRule item : items) {AclRuleBuilder builder = new AclRuleBuilder(item);_visitables.get("acls").add(builder);this.acls.add(builder);} return (A)this;
    }

    public A removeFromAcls(AclRule... items){
            for (AclRule item : items) {AclRuleBuilder builder = new AclRuleBuilder(item);_visitables.get("acls").remove(builder);if (this.acls != null) {this.acls.remove(builder);}} return (A)this;
    }

    public A removeAllFromAcls(Collection items){
            for (AclRule item : items) {AclRuleBuilder builder = new AclRuleBuilder(item);_visitables.get("acls").remove(builder);if (this.acls != null) {this.acls.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromAcls(io.fabric8.kubernetes.api.builder.Predicate predicate){
            if (acls == null) return (A) this;
            final Iterator each = acls.iterator();
            final List visitables = _visitables.get("acls");
            while (each.hasNext()) {
              AclRuleBuilder builder = each.next();
              if (predicate.apply(builder)) {
                visitables.remove(builder);
                each.remove();
              }
            }
            return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildAcls instead.
 * @return The buildable object.
 */
@Deprecated public List getAcls(){
            return build(acls);
    }

    public List buildAcls(){
            return build(acls);
    }

    public AclRule buildAcl(int index){
            return this.acls.get(index).build();
    }

    public AclRule buildFirstAcl(){
            return this.acls.get(0).build();
    }

    public AclRule buildLastAcl(){
            return this.acls.get(acls.size() - 1).build();
    }

    public AclRule buildMatchingAcl(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (AclRuleBuilder item: acls) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingAcl(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (AclRuleBuilder item: acls) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withAcls(List acls){
            if (this.acls != null) { _visitables.get("acls").removeAll(this.acls);}
            if (acls != null) {this.acls = new ArrayList(); for (AclRule item : acls){this.addToAcls(item);}} else { this.acls = null;} return (A) this;
    }

    public A withAcls(AclRule... acls){
            if (this.acls != null) {this.acls.clear();}
            if (acls != null) {for (AclRule item :acls){ this.addToAcls(item);}} return (A) this;
    }

    public Boolean hasAcls(){
            return acls != null && !acls.isEmpty();
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested addNewAcl(){
            return new AclsNestedImpl();
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested addNewAclLike(AclRule item){
            return new AclsNestedImpl(-1, item);
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested setNewAclLike(int index,AclRule item){
            return new AclsNestedImpl(index, item);
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested editAcl(int index){
            if (acls.size() <= index) throw new RuntimeException("Can't edit acls. Index exceeds size.");
            return setNewAclLike(index, buildAcl(index));
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested editFirstAcl(){
            if (acls.size() == 0) throw new RuntimeException("Can't edit first acls. The list is empty.");
            return setNewAclLike(0, buildAcl(0));
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested editLastAcl(){
            int index = acls.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last acls. The list is empty.");
            return setNewAclLike(index, buildAcl(index));
    }

    public KafkaUserAuthorizationSimpleFluent.AclsNested editMatchingAcl(io.fabric8.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends AclRuleFluentImpl> implements KafkaUserAuthorizationSimpleFluent.AclsNested,io.fabric8.kubernetes.api.builder.Nested{

            private final AclRuleBuilder builder;
        private final int index;
    
            AclsNestedImpl(int index,AclRule item){
                    this.index = index;
                    this.builder = new AclRuleBuilder(this, item);
            }
            AclsNestedImpl(){
                    this.index = -1;
                    this.builder = new AclRuleBuilder(this);
            }
    
    public N and(){
            return (N) KafkaUserAuthorizationSimpleFluentImpl.this.setToAcls(index, builder.build());
    }
    public N endAcl(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy