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

io.alauda.kubernetes.api.model.ConfigMapProjectionFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
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.Integer;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class ConfigMapProjectionFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ConfigMapProjectionFluent{

    private List items =  new ArrayList();
    private String name;
    private Boolean optional;

    public ConfigMapProjectionFluentImpl(){
    }
    public ConfigMapProjectionFluentImpl(ConfigMapProjection instance){
            this.withItems(instance.getItems()); 
            this.withName(instance.getName()); 
            this.withOptional(instance.getOptional()); 
    }

    public A addToItems(int index,KeyToPath item){
            KeyToPathBuilder builder = new KeyToPathBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.items.add(index >= 0 ? index : items.size(), builder); return (A)this;
    }

    public A setToItems(int index,KeyToPath item){
            KeyToPathBuilder builder = new KeyToPathBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= items.size()) { items.add(builder); } else { items.set(index, builder);}
             return (A)this;
    }

    public A addToItems(KeyToPath... items){
            for (KeyToPath item : items) {KeyToPathBuilder builder = new KeyToPathBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
    }

    public A addAllToItems(Collection items){
            for (KeyToPath item : items) {KeyToPathBuilder builder = new KeyToPathBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
    }

    public A removeFromItems(KeyToPath... items){
            for (KeyToPath item : items) {KeyToPathBuilder builder = new KeyToPathBuilder(item);_visitables.remove(builder);this.items.remove(builder);} return (A)this;
    }

    public A removeAllFromItems(Collection items){
            for (KeyToPath item : items) {KeyToPathBuilder builder = new KeyToPathBuilder(item);_visitables.remove(builder);this.items.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildItems instead.
 */
@Deprecated public List getItems(){
            return build(items);
    }

    public List buildItems(){
            return build(items);
    }

    public KeyToPath buildItem(int index){
            return this.items.get(index).build();
    }

    public KeyToPath buildFirstItem(){
            return this.items.get(0).build();
    }

    public KeyToPath buildLastItem(){
            return this.items.get(items.size() - 1).build();
    }

    public KeyToPath buildMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (KeyToPathBuilder item: items) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withItems(List items){
            _visitables.removeAll(this.items);
            this.items.clear();
            if (items != null) {for (KeyToPath item : items){this.addToItems(item);}} return (A) this;
    }

    public A withItems(KeyToPath... items){
            this.items.clear(); if (items != null) {for (KeyToPath item :items){ this.addToItems(item);}} return (A) this;
    }

    public Boolean hasItems(){
            return items!= null && !items.isEmpty();
    }

    public ConfigMapProjectionFluent.ItemsNested addNewItem(){
            return new ItemsNestedImpl();
    }

    public ConfigMapProjectionFluent.ItemsNested addNewItemLike(KeyToPath item){
            return new ItemsNestedImpl(-1, item);
    }

    public ConfigMapProjectionFluent.ItemsNested setNewItemLike(int index,KeyToPath item){
            return new ItemsNestedImpl(index, item);
    }

    public ConfigMapProjectionFluent.ItemsNested editItem(int index){
            if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
            return setNewItemLike(index, buildItem(index));
    }

    public ConfigMapProjectionFluent.ItemsNested editFirstItem(){
            if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
            return setNewItemLike(0, buildItem(0));
    }

    public ConfigMapProjectionFluent.ItemsNested editLastItem(){
            int index = items.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last items. The list is empty.");
            return setNewItemLike(index, buildItem(index));
    }

    public ConfigMapProjectionFluent.ItemsNested editMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends KeyToPathFluentImpl> implements ConfigMapProjectionFluent.ItemsNested,io.alauda.kubernetes.api.builder.Nested{

            private final KeyToPathBuilder builder;
        private final int index;
    
            ItemsNestedImpl(int index,KeyToPath item){
                    this.index = index;
                    this.builder = new KeyToPathBuilder(this, item);
            }
            ItemsNestedImpl(){
                    this.index = -1;
                    this.builder = new KeyToPathBuilder(this);
            }
    
    public N and(){
            return (N) ConfigMapProjectionFluentImpl.this.setToItems(index, builder.build());
    }
    public N endItem(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy