io.alauda.kubernetes.api.model.PipelineTemplateArgumentGroupFluentImpl 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 java.lang.String;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;
public class PipelineTemplateArgumentGroupFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PipelineTemplateArgumentGroupFluent{
private I18nNameBuilder displayName;
private List items = new ArrayList();
public PipelineTemplateArgumentGroupFluentImpl(){
}
public PipelineTemplateArgumentGroupFluentImpl(PipelineTemplateArgumentGroup instance){
this.withDisplayName(instance.getDisplayName());
this.withItems(instance.getItems());
}
/**
* This method has been deprecated, please use method buildDisplayName instead.
*/
@Deprecated public I18nName getDisplayName(){
return this.displayName!=null?this.displayName.build():null;
}
public I18nName buildDisplayName(){
return this.displayName!=null?this.displayName.build():null;
}
public A withDisplayName(I18nName displayName){
_visitables.remove(this.displayName);
if (displayName!=null){ this.displayName= new I18nNameBuilder(displayName); _visitables.add(this.displayName);} return (A) this;
}
public Boolean hasDisplayName(){
return this.displayName!=null;
}
public PipelineTemplateArgumentGroupFluent.DisplayNameNested withNewDisplayName(){
return new DisplayNameNestedImpl();
}
public PipelineTemplateArgumentGroupFluent.DisplayNameNested withNewDisplayNameLike(I18nName item){
return new DisplayNameNestedImpl(item);
}
public PipelineTemplateArgumentGroupFluent.DisplayNameNested editDisplayName(){
return withNewDisplayNameLike(getDisplayName());
}
public PipelineTemplateArgumentGroupFluent.DisplayNameNested editOrNewDisplayName(){
return withNewDisplayNameLike(getDisplayName() != null ? getDisplayName(): new I18nNameBuilder().build());
}
public PipelineTemplateArgumentGroupFluent.DisplayNameNested editOrNewDisplayNameLike(I18nName item){
return withNewDisplayNameLike(getDisplayName() != null ? getDisplayName(): item);
}
public A withNewDisplayName(String en,String zhCN){
return (A)withDisplayName(new I18nName(en, zhCN));
}
public A addToItems(int index,PipelineTemplateArgumentValue item){
PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(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,PipelineTemplateArgumentValue item){
PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(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(PipelineTemplateArgumentValue... items){
for (PipelineTemplateArgumentValue item : items) {PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A addAllToItems(Collection items){
for (PipelineTemplateArgumentValue item : items) {PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A removeFromItems(PipelineTemplateArgumentValue... items){
for (PipelineTemplateArgumentValue item : items) {PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(item);_visitables.remove(builder);this.items.remove(builder);} return (A)this;
}
public A removeAllFromItems(Collection items){
for (PipelineTemplateArgumentValue item : items) {PipelineTemplateArgumentValueBuilder builder = new PipelineTemplateArgumentValueBuilder(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 PipelineTemplateArgumentValue buildItem(int index){
return this.items.get(index).build();
}
public PipelineTemplateArgumentValue buildFirstItem(){
return this.items.get(0).build();
}
public PipelineTemplateArgumentValue buildLastItem(){
return this.items.get(items.size() - 1).build();
}
public PipelineTemplateArgumentValue buildMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
for (PipelineTemplateArgumentValueBuilder 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 (PipelineTemplateArgumentValue item : items){this.addToItems(item);}} return (A) this;
}
public A withItems(PipelineTemplateArgumentValue... items){
this.items.clear(); if (items != null) {for (PipelineTemplateArgumentValue item :items){ this.addToItems(item);}} return (A) this;
}
public Boolean hasItems(){
return items!= null && !items.isEmpty();
}
public PipelineTemplateArgumentGroupFluent.ItemsNested addNewItem(){
return new ItemsNestedImpl();
}
public PipelineTemplateArgumentGroupFluent.ItemsNested addNewItemLike(PipelineTemplateArgumentValue item){
return new ItemsNestedImpl(-1, item);
}
public PipelineTemplateArgumentGroupFluent.ItemsNested setNewItemLike(int index,PipelineTemplateArgumentValue item){
return new ItemsNestedImpl(index, item);
}
public PipelineTemplateArgumentGroupFluent.ItemsNested editItem(int index){
if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
return setNewItemLike(index, buildItem(index));
}
public PipelineTemplateArgumentGroupFluent.ItemsNested editFirstItem(){
if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
return setNewItemLike(0, buildItem(0));
}
public PipelineTemplateArgumentGroupFluent.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 PipelineTemplateArgumentGroupFluent.ItemsNested editMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends I18nNameFluentImpl> implements PipelineTemplateArgumentGroupFluent.DisplayNameNested,io.alauda.kubernetes.api.builder.Nested{
private final I18nNameBuilder builder;
DisplayNameNestedImpl(I18nName item){
this.builder = new I18nNameBuilder(this, item);
}
DisplayNameNestedImpl(){
this.builder = new I18nNameBuilder(this);
}
public N and(){
return (N) PipelineTemplateArgumentGroupFluentImpl.this.withDisplayName(builder.build());
}
public N endDisplayName(){
return and();
}
}
public class ItemsNestedImpl extends PipelineTemplateArgumentValueFluentImpl> implements PipelineTemplateArgumentGroupFluent.ItemsNested,io.alauda.kubernetes.api.builder.Nested{
private final PipelineTemplateArgumentValueBuilder builder;
private final int index;
ItemsNestedImpl(int index,PipelineTemplateArgumentValue item){
this.index = index;
this.builder = new PipelineTemplateArgumentValueBuilder(this, item);
}
ItemsNestedImpl(){
this.index = -1;
this.builder = new PipelineTemplateArgumentValueBuilder(this);
}
public N and(){
return (N) PipelineTemplateArgumentGroupFluentImpl.this.setToItems(index, builder.build());
}
public N endItem(){
return and();
}
}
}