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

io.alauda.devops.api.model.SupplementalGroupsStrategyOptionsFluentImpl 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 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 SupplementalGroupsStrategyOptionsFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements SupplementalGroupsStrategyOptionsFluent{

    private List ranges =  new ArrayList();
    private String type;

    public SupplementalGroupsStrategyOptionsFluentImpl(){
    }
    public SupplementalGroupsStrategyOptionsFluentImpl(SupplementalGroupsStrategyOptions instance){
            this.withRanges(instance.getRanges()); 
            this.withType(instance.getType()); 
    }

    public A addToRanges(int index,IDRange item){
            IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.ranges.add(index >= 0 ? index : ranges.size(), builder); return (A)this;
    }

    public A setToRanges(int index,IDRange item){
            IDRangeBuilder builder = new IDRangeBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= ranges.size()) { ranges.add(builder); } else { ranges.set(index, builder);}
             return (A)this;
    }

    public A addToRanges(IDRange... items){
            for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(builder);this.ranges.add(builder);} return (A)this;
    }

    public A addAllToRanges(Collection items){
            for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.add(builder);this.ranges.add(builder);} return (A)this;
    }

    public A removeFromRanges(IDRange... items){
            for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.remove(builder);this.ranges.remove(builder);} return (A)this;
    }

    public A removeAllFromRanges(Collection items){
            for (IDRange item : items) {IDRangeBuilder builder = new IDRangeBuilder(item);_visitables.remove(builder);this.ranges.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildRanges instead.
 */
@Deprecated public List getRanges(){
            return build(ranges);
    }

    public List buildRanges(){
            return build(ranges);
    }

    public IDRange buildRange(int index){
            return this.ranges.get(index).build();
    }

    public IDRange buildFirstRange(){
            return this.ranges.get(0).build();
    }

    public IDRange buildLastRange(){
            return this.ranges.get(ranges.size() - 1).build();
    }

    public IDRange buildMatchingRange(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (IDRangeBuilder item: ranges) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withRanges(List ranges){
            _visitables.removeAll(this.ranges);
            this.ranges.clear();
            if (ranges != null) {for (IDRange item : ranges){this.addToRanges(item);}} return (A) this;
    }

    public A withRanges(IDRange... ranges){
            this.ranges.clear(); if (ranges != null) {for (IDRange item :ranges){ this.addToRanges(item);}} return (A) this;
    }

    public Boolean hasRanges(){
            return ranges!= null && !ranges.isEmpty();
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested addNewRange(){
            return new RangesNestedImpl();
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested addNewRangeLike(IDRange item){
            return new RangesNestedImpl(-1, item);
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested setNewRangeLike(int index,IDRange item){
            return new RangesNestedImpl(index, item);
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested editRange(int index){
            if (ranges.size() <= index) throw new RuntimeException("Can't edit ranges. Index exceeds size.");
            return setNewRangeLike(index, buildRange(index));
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested editFirstRange(){
            if (ranges.size() == 0) throw new RuntimeException("Can't edit first ranges. The list is empty.");
            return setNewRangeLike(0, buildRange(0));
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested editLastRange(){
            int index = ranges.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last ranges. The list is empty.");
            return setNewRangeLike(index, buildRange(index));
    }

    public SupplementalGroupsStrategyOptionsFluent.RangesNested editMatchingRange(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends IDRangeFluentImpl> implements SupplementalGroupsStrategyOptionsFluent.RangesNested,io.alauda.kubernetes.api.builder.Nested{

            private final IDRangeBuilder builder;
        private final int index;
    
            RangesNestedImpl(int index,IDRange item){
                    this.index = index;
                    this.builder = new IDRangeBuilder(this, item);
            }
            RangesNestedImpl(){
                    this.index = -1;
                    this.builder = new IDRangeBuilder(this);
            }
    
    public N and(){
            return (N) SupplementalGroupsStrategyOptionsFluentImpl.this.setToRanges(index, builder.build());
    }
    public N endRange(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy