io.alauda.kubernetes.api.model.DownwardAPIProjectionFluentImpl 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 io.alauda.kubernetes.api.builder.Predicate;
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 DownwardAPIProjectionFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements DownwardAPIProjectionFluent{
private List items = new ArrayList();
public DownwardAPIProjectionFluentImpl(){
}
public DownwardAPIProjectionFluentImpl(DownwardAPIProjection instance){
this.withItems(instance.getItems());
}
public A addToItems(int index,DownwardAPIVolumeFile item){
DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(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,DownwardAPIVolumeFile item){
DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(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(DownwardAPIVolumeFile... items){
for (DownwardAPIVolumeFile item : items) {DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A addAllToItems(Collection items){
for (DownwardAPIVolumeFile item : items) {DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A removeFromItems(DownwardAPIVolumeFile... items){
for (DownwardAPIVolumeFile item : items) {DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(item);_visitables.remove(builder);this.items.remove(builder);} return (A)this;
}
public A removeAllFromItems(Collection items){
for (DownwardAPIVolumeFile item : items) {DownwardAPIVolumeFileBuilder builder = new DownwardAPIVolumeFileBuilder(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 DownwardAPIVolumeFile buildItem(int index){
return this.items.get(index).build();
}
public DownwardAPIVolumeFile buildFirstItem(){
return this.items.get(0).build();
}
public DownwardAPIVolumeFile buildLastItem(){
return this.items.get(items.size() - 1).build();
}
public DownwardAPIVolumeFile buildMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
for (DownwardAPIVolumeFileBuilder 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 (DownwardAPIVolumeFile item : items){this.addToItems(item);}} return (A) this;
}
public A withItems(DownwardAPIVolumeFile... items){
this.items.clear(); if (items != null) {for (DownwardAPIVolumeFile item :items){ this.addToItems(item);}} return (A) this;
}
public Boolean hasItems(){
return items!= null && !items.isEmpty();
}
public DownwardAPIProjectionFluent.ItemsNested addNewItem(){
return new ItemsNestedImpl();
}
public DownwardAPIProjectionFluent.ItemsNested addNewItemLike(DownwardAPIVolumeFile item){
return new ItemsNestedImpl(-1, item);
}
public DownwardAPIProjectionFluent.ItemsNested setNewItemLike(int index,DownwardAPIVolumeFile item){
return new ItemsNestedImpl(index, item);
}
public DownwardAPIProjectionFluent.ItemsNested editItem(int index){
if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
return setNewItemLike(index, buildItem(index));
}
public DownwardAPIProjectionFluent.ItemsNested editFirstItem(){
if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
return setNewItemLike(0, buildItem(0));
}
public DownwardAPIProjectionFluent.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 DownwardAPIProjectionFluent.ItemsNested editMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends DownwardAPIVolumeFileFluentImpl> implements DownwardAPIProjectionFluent.ItemsNested,io.alauda.kubernetes.api.builder.Nested{
private final DownwardAPIVolumeFileBuilder builder;
private final int index;
ItemsNestedImpl(int index,DownwardAPIVolumeFile item){
this.index = index;
this.builder = new DownwardAPIVolumeFileBuilder(this, item);
}
ItemsNestedImpl(){
this.index = -1;
this.builder = new DownwardAPIVolumeFileBuilder(this);
}
public N and(){
return (N) DownwardAPIProjectionFluentImpl.this.setToItems(index, builder.build());
}
public N endItem(){
return and();
}
}
}