io.alauda.kubernetes.api.model.policy.PodDisruptionBudgetListFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model.policy;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import javax.validation.constraints.NotNull;
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 io.alauda.kubernetes.api.model.ListMeta;
import io.alauda.kubernetes.api.model.ListMetaBuilder;
import javax.validation.Valid;
import io.alauda.kubernetes.api.model.ListMetaFluentImpl;
import java.util.Collection;
import java.lang.Object;
public class PodDisruptionBudgetListFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PodDisruptionBudgetListFluent{
private String apiVersion;
private List items = new ArrayList();
private String kind;
private ListMetaBuilder metadata;
public PodDisruptionBudgetListFluentImpl(){
}
public PodDisruptionBudgetListFluentImpl(PodDisruptionBudgetList instance){
this.withApiVersion(instance.getApiVersion());
this.withItems(instance.getItems());
this.withKind(instance.getKind());
this.withMetadata(instance.getMetadata());
}
public String getApiVersion(){
return this.apiVersion;
}
public A withApiVersion(String apiVersion){
this.apiVersion=apiVersion; return (A) this;
}
public Boolean hasApiVersion(){
return this.apiVersion!=null;
}
public A addToItems(int index,PodDisruptionBudget item){
PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(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,PodDisruptionBudget item){
PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(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(PodDisruptionBudget... items){
for (PodDisruptionBudget item : items) {PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A addAllToItems(Collection items){
for (PodDisruptionBudget item : items) {PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(item);_visitables.add(builder);this.items.add(builder);} return (A)this;
}
public A removeFromItems(PodDisruptionBudget... items){
for (PodDisruptionBudget item : items) {PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(item);_visitables.remove(builder);this.items.remove(builder);} return (A)this;
}
public A removeAllFromItems(Collection items){
for (PodDisruptionBudget item : items) {PodDisruptionBudgetBuilder builder = new PodDisruptionBudgetBuilder(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 PodDisruptionBudget buildItem(int index){
return this.items.get(index).build();
}
public PodDisruptionBudget buildFirstItem(){
return this.items.get(0).build();
}
public PodDisruptionBudget buildLastItem(){
return this.items.get(items.size() - 1).build();
}
public PodDisruptionBudget buildMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
for (PodDisruptionBudgetBuilder 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 (PodDisruptionBudget item : items){this.addToItems(item);}} return (A) this;
}
public A withItems(PodDisruptionBudget... items){
this.items.clear(); if (items != null) {for (PodDisruptionBudget item :items){ this.addToItems(item);}} return (A) this;
}
public Boolean hasItems(){
return items!= null && !items.isEmpty();
}
public PodDisruptionBudgetListFluent.ItemsNested addNewItem(){
return new ItemsNestedImpl();
}
public PodDisruptionBudgetListFluent.ItemsNested addNewItemLike(PodDisruptionBudget item){
return new ItemsNestedImpl(-1, item);
}
public PodDisruptionBudgetListFluent.ItemsNested setNewItemLike(int index,PodDisruptionBudget item){
return new ItemsNestedImpl(index, item);
}
public PodDisruptionBudgetListFluent.ItemsNested editItem(int index){
if (items.size() <= index) throw new RuntimeException("Can't edit items. Index exceeds size.");
return setNewItemLike(index, buildItem(index));
}
public PodDisruptionBudgetListFluent.ItemsNested editFirstItem(){
if (items.size() == 0) throw new RuntimeException("Can't edit first items. The list is empty.");
return setNewItemLike(0, buildItem(0));
}
public PodDisruptionBudgetListFluent.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 PodDisruptionBudgetListFluent.ItemsNested editMatchingItem(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewMetadata(){
return new MetadataNestedImpl();
}
public PodDisruptionBudgetListFluent.MetadataNested withNewMetadataLike(ListMeta item){
return new MetadataNestedImpl(item);
}
public PodDisruptionBudgetListFluent.MetadataNested editMetadata(){
return withNewMetadataLike(getMetadata());
}
public PodDisruptionBudgetListFluent.MetadataNested editOrNewMetadata(){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ListMetaBuilder().build());
}
public PodDisruptionBudgetListFluent.MetadataNested editOrNewMetadataLike(ListMeta item){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
public A withNewMetadata(String resourceVersion,String selfLink){
return (A)withMetadata(new ListMeta(resourceVersion, selfLink));
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
PodDisruptionBudgetListFluentImpl that = (PodDisruptionBudgetListFluentImpl) o;
if (apiVersion != null ? !apiVersion.equals(that.apiVersion) :that.apiVersion != null) return false;
if (items != null ? !items.equals(that.items) :that.items != null) return false;
if (kind != null ? !kind.equals(that.kind) :that.kind != null) return false;
if (metadata != null ? !metadata.equals(that.metadata) :that.metadata != null) return false;
return true;
}
public class ItemsNestedImpl extends PodDisruptionBudgetFluentImpl> implements PodDisruptionBudgetListFluent.ItemsNested,io.alauda.kubernetes.api.builder.Nested{
private final PodDisruptionBudgetBuilder builder;
private final int index;
ItemsNestedImpl(int index,PodDisruptionBudget item){
this.index = index;
this.builder = new PodDisruptionBudgetBuilder(this, item);
}
ItemsNestedImpl(){
this.index = -1;
this.builder = new PodDisruptionBudgetBuilder(this);
}
public N and(){
return (N) PodDisruptionBudgetListFluentImpl.this.setToItems(index, builder.build());
}
public N endItem(){
return and();
}
}
public class MetadataNestedImpl extends ListMetaFluentImpl> implements PodDisruptionBudgetListFluent.MetadataNested,io.alauda.kubernetes.api.builder.Nested{
private final ListMetaBuilder builder;
MetadataNestedImpl(ListMeta item){
this.builder = new ListMetaBuilder(this, item);
}
MetadataNestedImpl(){
this.builder = new ListMetaBuilder(this);
}
public N and(){
return (N) PodDisruptionBudgetListFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata(){
return and();
}
}
}