io.alauda.kubernetes.api.model.PreferencesFluentImpl 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 PreferencesFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements PreferencesFluent{
private Boolean colors;
private List extensions = new ArrayList();
public PreferencesFluentImpl(){
}
public PreferencesFluentImpl(Preferences instance){
this.withColors(instance.getColors());
this.withExtensions(instance.getExtensions());
}
public Boolean isColors(){
return this.colors;
}
public A withColors(Boolean colors){
this.colors=colors; return (A) this;
}
public Boolean hasColors(){
return this.colors!=null;
}
public A addToExtensions(int index,NamedExtension item){
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.extensions.add(index >= 0 ? index : extensions.size(), builder); return (A)this;
}
public A setToExtensions(int index,NamedExtension item){
NamedExtensionBuilder builder = new NamedExtensionBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= extensions.size()) { extensions.add(builder); } else { extensions.set(index, builder);}
return (A)this;
}
public A addToExtensions(NamedExtension... items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(builder);this.extensions.add(builder);} return (A)this;
}
public A addAllToExtensions(Collection items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.add(builder);this.extensions.add(builder);} return (A)this;
}
public A removeFromExtensions(NamedExtension... items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.remove(builder);this.extensions.remove(builder);} return (A)this;
}
public A removeAllFromExtensions(Collection items){
for (NamedExtension item : items) {NamedExtensionBuilder builder = new NamedExtensionBuilder(item);_visitables.remove(builder);this.extensions.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildExtensions instead.
*/
@Deprecated public List getExtensions(){
return build(extensions);
}
public List buildExtensions(){
return build(extensions);
}
public NamedExtension buildExtension(int index){
return this.extensions.get(index).build();
}
public NamedExtension buildFirstExtension(){
return this.extensions.get(0).build();
}
public NamedExtension buildLastExtension(){
return this.extensions.get(extensions.size() - 1).build();
}
public NamedExtension buildMatchingExtension(io.alauda.kubernetes.api.builder.Predicate predicate){
for (NamedExtensionBuilder item: extensions) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withExtensions(List extensions){
_visitables.removeAll(this.extensions);
this.extensions.clear();
if (extensions != null) {for (NamedExtension item : extensions){this.addToExtensions(item);}} return (A) this;
}
public A withExtensions(NamedExtension... extensions){
this.extensions.clear(); if (extensions != null) {for (NamedExtension item :extensions){ this.addToExtensions(item);}} return (A) this;
}
public Boolean hasExtensions(){
return extensions!= null && !extensions.isEmpty();
}
public PreferencesFluent.ExtensionsNested addNewExtension(){
return new ExtensionsNestedImpl();
}
public PreferencesFluent.ExtensionsNested addNewExtensionLike(NamedExtension item){
return new ExtensionsNestedImpl(-1, item);
}
public PreferencesFluent.ExtensionsNested setNewExtensionLike(int index,NamedExtension item){
return new ExtensionsNestedImpl(index, item);
}
public PreferencesFluent.ExtensionsNested editExtension(int index){
if (extensions.size() <= index) throw new RuntimeException("Can't edit extensions. Index exceeds size.");
return setNewExtensionLike(index, buildExtension(index));
}
public PreferencesFluent.ExtensionsNested editFirstExtension(){
if (extensions.size() == 0) throw new RuntimeException("Can't edit first extensions. The list is empty.");
return setNewExtensionLike(0, buildExtension(0));
}
public PreferencesFluent.ExtensionsNested editLastExtension(){
int index = extensions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last extensions. The list is empty.");
return setNewExtensionLike(index, buildExtension(index));
}
public PreferencesFluent.ExtensionsNested editMatchingExtension(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends NamedExtensionFluentImpl> implements PreferencesFluent.ExtensionsNested,io.alauda.kubernetes.api.builder.Nested{
private final NamedExtensionBuilder builder;
private final int index;
ExtensionsNestedImpl(int index,NamedExtension item){
this.index = index;
this.builder = new NamedExtensionBuilder(this, item);
}
ExtensionsNestedImpl(){
this.index = -1;
this.builder = new NamedExtensionBuilder(this);
}
public N and(){
return (N) PreferencesFluentImpl.this.setToExtensions(index, builder.build());
}
public N endExtension(){
return and();
}
}
}