annotations.io.alauda.kubernetes.api.model.ProjectedVolumeSourceFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
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 ProjectedVolumeSourceFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ProjectedVolumeSourceFluent{
private Integer defaultMode;
private List sources = new ArrayList();
public ProjectedVolumeSourceFluentImpl(){
}
public ProjectedVolumeSourceFluentImpl(ProjectedVolumeSource instance){
this.withDefaultMode(instance.getDefaultMode());
this.withSources(instance.getSources());
}
public Integer getDefaultMode(){
return this.defaultMode;
}
public A withDefaultMode(Integer defaultMode){
this.defaultMode=defaultMode; return (A) this;
}
public Boolean hasDefaultMode(){
return this.defaultMode!=null;
}
public A addToSources(int index,VolumeProjection item){
VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.sources.add(index >= 0 ? index : sources.size(), builder); return (A)this;
}
public A setToSources(int index,VolumeProjection item){
VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= sources.size()) { sources.add(builder); } else { sources.set(index, builder);}
return (A)this;
}
public A addToSources(VolumeProjection... items){
for (VolumeProjection item : items) {VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);_visitables.add(builder);this.sources.add(builder);} return (A)this;
}
public A addAllToSources(Collection items){
for (VolumeProjection item : items) {VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);_visitables.add(builder);this.sources.add(builder);} return (A)this;
}
public A removeFromSources(VolumeProjection... items){
for (VolumeProjection item : items) {VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);_visitables.remove(builder);this.sources.remove(builder);} return (A)this;
}
public A removeAllFromSources(Collection items){
for (VolumeProjection item : items) {VolumeProjectionBuilder builder = new VolumeProjectionBuilder(item);_visitables.remove(builder);this.sources.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildSources instead.
*/
@Deprecated public List getSources(){
return build(sources);
}
public List buildSources(){
return build(sources);
}
public VolumeProjection buildSource(int index){
return this.sources.get(index).build();
}
public VolumeProjection buildFirstSource(){
return this.sources.get(0).build();
}
public VolumeProjection buildLastSource(){
return this.sources.get(sources.size() - 1).build();
}
public VolumeProjection buildMatchingSource(io.alauda.kubernetes.api.builder.Predicate predicate){
for (VolumeProjectionBuilder item: sources) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withSources(List sources){
_visitables.removeAll(this.sources);
this.sources.clear();
if (sources != null) {for (VolumeProjection item : sources){this.addToSources(item);}} return (A) this;
}
public A withSources(VolumeProjection... sources){
this.sources.clear(); if (sources != null) {for (VolumeProjection item :sources){ this.addToSources(item);}} return (A) this;
}
public Boolean hasSources(){
return sources!= null && !sources.isEmpty();
}
public ProjectedVolumeSourceFluent.SourcesNested addNewSource(){
return new SourcesNestedImpl();
}
public ProjectedVolumeSourceFluent.SourcesNested addNewSourceLike(VolumeProjection item){
return new SourcesNestedImpl(-1, item);
}
public ProjectedVolumeSourceFluent.SourcesNested setNewSourceLike(int index,VolumeProjection item){
return new SourcesNestedImpl(index, item);
}
public ProjectedVolumeSourceFluent.SourcesNested editSource(int index){
if (sources.size() <= index) throw new RuntimeException("Can't edit sources. Index exceeds size.");
return setNewSourceLike(index, buildSource(index));
}
public ProjectedVolumeSourceFluent.SourcesNested editFirstSource(){
if (sources.size() == 0) throw new RuntimeException("Can't edit first sources. The list is empty.");
return setNewSourceLike(0, buildSource(0));
}
public ProjectedVolumeSourceFluent.SourcesNested editLastSource(){
int index = sources.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last sources. The list is empty.");
return setNewSourceLike(index, buildSource(index));
}
public ProjectedVolumeSourceFluent.SourcesNested editMatchingSource(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends VolumeProjectionFluentImpl> implements ProjectedVolumeSourceFluent.SourcesNested,io.alauda.kubernetes.api.builder.Nested{
private final VolumeProjectionBuilder builder;
private final int index;
SourcesNestedImpl(int index,VolumeProjection item){
this.index = index;
this.builder = new VolumeProjectionBuilder(this, item);
}
SourcesNestedImpl(){
this.index = -1;
this.builder = new VolumeProjectionBuilder(this);
}
public N and(){
return (N) ProjectedVolumeSourceFluentImpl.this.setToSources(index, builder.build());
}
public N endSource(){
return and();
}
}
}