io.fabric8.tekton.triggers.v1alpha1.TriggerSpecFluent Maven / Gradle / Ivy
package io.fabric8.tekton.triggers.v1alpha1;
import io.fabric8.kubernetes.api.builder.VisitableBuilder;
import java.lang.SuppressWarnings;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import java.util.LinkedHashMap;
import java.util.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.util.Collection;
import java.lang.Object;
import java.util.Map;
/**
* Generated
*/
@SuppressWarnings("unchecked")
public class TriggerSpecFluent> extends BaseFluent{
public TriggerSpecFluent() {
}
public TriggerSpecFluent(TriggerSpec instance) {
this.copyInstance(instance);
}
private ArrayList bindings = new ArrayList();
private ArrayList interceptors = new ArrayList();
private String name;
private String serviceAccountName;
private TriggerSpecTemplateBuilder template;
private Map additionalProperties;
protected void copyInstance(TriggerSpec instance) {
instance = (instance != null ? instance : new TriggerSpec());
if (instance != null) {
this.withBindings(instance.getBindings());
this.withInterceptors(instance.getInterceptors());
this.withName(instance.getName());
this.withServiceAccountName(instance.getServiceAccountName());
this.withTemplate(instance.getTemplate());
this.withAdditionalProperties(instance.getAdditionalProperties());
}
}
public A addToBindings(int index,TriggerSpecBinding item) {
if (this.bindings == null) {this.bindings = new ArrayList();}
TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);
if (index < 0 || index >= bindings.size()) { _visitables.get("bindings").add(builder); bindings.add(builder); } else { _visitables.get("bindings").add(index, builder); bindings.add(index, builder);}
return (A)this;
}
public A setToBindings(int index,TriggerSpecBinding item) {
if (this.bindings == null) {this.bindings = new ArrayList();}
TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);
if (index < 0 || index >= bindings.size()) { _visitables.get("bindings").add(builder); bindings.add(builder); } else { _visitables.get("bindings").set(index, builder); bindings.set(index, builder);}
return (A)this;
}
public A addToBindings(io.fabric8.tekton.triggers.v1alpha1.TriggerSpecBinding... items) {
if (this.bindings == null) {this.bindings = new ArrayList();}
for (TriggerSpecBinding item : items) {TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);_visitables.get("bindings").add(builder);this.bindings.add(builder);} return (A)this;
}
public A addAllToBindings(Collection items) {
if (this.bindings == null) {this.bindings = new ArrayList();}
for (TriggerSpecBinding item : items) {TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);_visitables.get("bindings").add(builder);this.bindings.add(builder);} return (A)this;
}
public A removeFromBindings(io.fabric8.tekton.triggers.v1alpha1.TriggerSpecBinding... items) {
if (this.bindings == null) return (A)this;
for (TriggerSpecBinding item : items) {TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);_visitables.get("bindings").remove(builder); this.bindings.remove(builder);} return (A)this;
}
public A removeAllFromBindings(Collection items) {
if (this.bindings == null) return (A)this;
for (TriggerSpecBinding item : items) {TriggerSpecBindingBuilder builder = new TriggerSpecBindingBuilder(item);_visitables.get("bindings").remove(builder); this.bindings.remove(builder);} return (A)this;
}
public A removeMatchingFromBindings(Predicate predicate) {
if (bindings == null) return (A) this;
final Iterator each = bindings.iterator();
final List visitables = _visitables.get("bindings");
while (each.hasNext()) {
TriggerSpecBindingBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildBindings() {
return this.bindings != null ? build(bindings) : null;
}
public TriggerSpecBinding buildBinding(int index) {
return this.bindings.get(index).build();
}
public TriggerSpecBinding buildFirstBinding() {
return this.bindings.get(0).build();
}
public TriggerSpecBinding buildLastBinding() {
return this.bindings.get(bindings.size() - 1).build();
}
public TriggerSpecBinding buildMatchingBinding(Predicate predicate) {
for (TriggerSpecBindingBuilder item : bindings) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingBinding(Predicate predicate) {
for (TriggerSpecBindingBuilder item : bindings) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withBindings(List bindings) {
if (this.bindings != null) {
this._visitables.get("bindings").clear();
}
if (bindings != null) {
this.bindings = new ArrayList();
for (TriggerSpecBinding item : bindings) {
this.addToBindings(item);
}
} else {
this.bindings = null;
}
return (A) this;
}
public A withBindings(io.fabric8.tekton.triggers.v1alpha1.TriggerSpecBinding... bindings) {
if (this.bindings != null) {
this.bindings.clear();
_visitables.remove("bindings");
}
if (bindings != null) {
for (TriggerSpecBinding item : bindings) {
this.addToBindings(item);
}
}
return (A) this;
}
public boolean hasBindings() {
return this.bindings != null && !this.bindings.isEmpty();
}
public A addNewBinding(String apiversion,String kind,String name,String ref,String value) {
return (A)addToBindings(new TriggerSpecBinding(apiversion, kind, name, ref, value));
}
public BindingsNested addNewBinding() {
return new BindingsNested(-1, null);
}
public BindingsNested addNewBindingLike(TriggerSpecBinding item) {
return new BindingsNested(-1, item);
}
public BindingsNested setNewBindingLike(int index,TriggerSpecBinding item) {
return new BindingsNested(index, item);
}
public BindingsNested editBinding(int index) {
if (bindings.size() <= index) throw new RuntimeException("Can't edit bindings. Index exceeds size.");
return setNewBindingLike(index, buildBinding(index));
}
public BindingsNested editFirstBinding() {
if (bindings.size() == 0) throw new RuntimeException("Can't edit first bindings. The list is empty.");
return setNewBindingLike(0, buildBinding(0));
}
public BindingsNested editLastBinding() {
int index = bindings.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last bindings. The list is empty.");
return setNewBindingLike(index, buildBinding(index));
}
public BindingsNested editMatchingBinding(Predicate predicate) {
int index = -1;
for (int i=0;i();}
TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);
if (index < 0 || index >= interceptors.size()) { _visitables.get("interceptors").add(builder); interceptors.add(builder); } else { _visitables.get("interceptors").add(index, builder); interceptors.add(index, builder);}
return (A)this;
}
public A setToInterceptors(int index,TriggerInterceptor item) {
if (this.interceptors == null) {this.interceptors = new ArrayList();}
TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);
if (index < 0 || index >= interceptors.size()) { _visitables.get("interceptors").add(builder); interceptors.add(builder); } else { _visitables.get("interceptors").set(index, builder); interceptors.set(index, builder);}
return (A)this;
}
public A addToInterceptors(io.fabric8.tekton.triggers.v1alpha1.TriggerInterceptor... items) {
if (this.interceptors == null) {this.interceptors = new ArrayList();}
for (TriggerInterceptor item : items) {TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);_visitables.get("interceptors").add(builder);this.interceptors.add(builder);} return (A)this;
}
public A addAllToInterceptors(Collection items) {
if (this.interceptors == null) {this.interceptors = new ArrayList();}
for (TriggerInterceptor item : items) {TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);_visitables.get("interceptors").add(builder);this.interceptors.add(builder);} return (A)this;
}
public A removeFromInterceptors(io.fabric8.tekton.triggers.v1alpha1.TriggerInterceptor... items) {
if (this.interceptors == null) return (A)this;
for (TriggerInterceptor item : items) {TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);_visitables.get("interceptors").remove(builder); this.interceptors.remove(builder);} return (A)this;
}
public A removeAllFromInterceptors(Collection items) {
if (this.interceptors == null) return (A)this;
for (TriggerInterceptor item : items) {TriggerInterceptorBuilder builder = new TriggerInterceptorBuilder(item);_visitables.get("interceptors").remove(builder); this.interceptors.remove(builder);} return (A)this;
}
public A removeMatchingFromInterceptors(Predicate predicate) {
if (interceptors == null) return (A) this;
final Iterator each = interceptors.iterator();
final List visitables = _visitables.get("interceptors");
while (each.hasNext()) {
TriggerInterceptorBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildInterceptors() {
return this.interceptors != null ? build(interceptors) : null;
}
public TriggerInterceptor buildInterceptor(int index) {
return this.interceptors.get(index).build();
}
public TriggerInterceptor buildFirstInterceptor() {
return this.interceptors.get(0).build();
}
public TriggerInterceptor buildLastInterceptor() {
return this.interceptors.get(interceptors.size() - 1).build();
}
public TriggerInterceptor buildMatchingInterceptor(Predicate predicate) {
for (TriggerInterceptorBuilder item : interceptors) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingInterceptor(Predicate predicate) {
for (TriggerInterceptorBuilder item : interceptors) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withInterceptors(List interceptors) {
if (this.interceptors != null) {
this._visitables.get("interceptors").clear();
}
if (interceptors != null) {
this.interceptors = new ArrayList();
for (TriggerInterceptor item : interceptors) {
this.addToInterceptors(item);
}
} else {
this.interceptors = null;
}
return (A) this;
}
public A withInterceptors(io.fabric8.tekton.triggers.v1alpha1.TriggerInterceptor... interceptors) {
if (this.interceptors != null) {
this.interceptors.clear();
_visitables.remove("interceptors");
}
if (interceptors != null) {
for (TriggerInterceptor item : interceptors) {
this.addToInterceptors(item);
}
}
return (A) this;
}
public boolean hasInterceptors() {
return this.interceptors != null && !this.interceptors.isEmpty();
}
public InterceptorsNested addNewInterceptor() {
return new InterceptorsNested(-1, null);
}
public InterceptorsNested addNewInterceptorLike(TriggerInterceptor item) {
return new InterceptorsNested(-1, item);
}
public InterceptorsNested setNewInterceptorLike(int index,TriggerInterceptor item) {
return new InterceptorsNested(index, item);
}
public InterceptorsNested editInterceptor(int index) {
if (interceptors.size() <= index) throw new RuntimeException("Can't edit interceptors. Index exceeds size.");
return setNewInterceptorLike(index, buildInterceptor(index));
}
public InterceptorsNested editFirstInterceptor() {
if (interceptors.size() == 0) throw new RuntimeException("Can't edit first interceptors. The list is empty.");
return setNewInterceptorLike(0, buildInterceptor(0));
}
public InterceptorsNested editLastInterceptor() {
int index = interceptors.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last interceptors. The list is empty.");
return setNewInterceptorLike(index, buildInterceptor(index));
}
public InterceptorsNested editMatchingInterceptor(Predicate predicate) {
int index = -1;
for (int i=0;i withNewTemplate() {
return new TemplateNested(null);
}
public TemplateNested withNewTemplateLike(TriggerSpecTemplate item) {
return new TemplateNested(item);
}
public TemplateNested editTemplate() {
return withNewTemplateLike(java.util.Optional.ofNullable(buildTemplate()).orElse(null));
}
public TemplateNested editOrNewTemplate() {
return withNewTemplateLike(java.util.Optional.ofNullable(buildTemplate()).orElse(new TriggerSpecTemplateBuilder().build()));
}
public TemplateNested editOrNewTemplateLike(TriggerSpecTemplate item) {
return withNewTemplateLike(java.util.Optional.ofNullable(buildTemplate()).orElse(item));
}
public A addToAdditionalProperties(String key,Object value) {
if(this.additionalProperties == null && key != null && value != null) { this.additionalProperties = new LinkedHashMap(); }
if(key != null && value != null) {this.additionalProperties.put(key, value);} return (A)this;
}
public A addToAdditionalProperties(Map map) {
if(this.additionalProperties == null && map != null) { this.additionalProperties = new LinkedHashMap(); }
if(map != null) { this.additionalProperties.putAll(map);} return (A)this;
}
public A removeFromAdditionalProperties(String key) {
if(this.additionalProperties == null) { return (A) this; }
if(key != null && this.additionalProperties != null) {this.additionalProperties.remove(key);} return (A)this;
}
public A removeFromAdditionalProperties(Map map) {
if(this.additionalProperties == null) { return (A) this; }
if(map != null) { for(Object key : map.keySet()) {if (this.additionalProperties != null){this.additionalProperties.remove(key);}}} return (A)this;
}
public Map getAdditionalProperties() {
return this.additionalProperties;
}
public A withAdditionalProperties(Map additionalProperties) {
if (additionalProperties == null) {
this.additionalProperties = null;
} else {
this.additionalProperties = new LinkedHashMap(additionalProperties);
}
return (A) this;
}
public boolean hasAdditionalProperties() {
return this.additionalProperties != null;
}
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
TriggerSpecFluent that = (TriggerSpecFluent) o;
if (!java.util.Objects.equals(bindings, that.bindings)) return false;
if (!java.util.Objects.equals(interceptors, that.interceptors)) return false;
if (!java.util.Objects.equals(name, that.name)) return false;
if (!java.util.Objects.equals(serviceAccountName, that.serviceAccountName)) return false;
if (!java.util.Objects.equals(template, that.template)) return false;
if (!java.util.Objects.equals(additionalProperties, that.additionalProperties)) return false;
return true;
}
public int hashCode() {
return java.util.Objects.hash(bindings, interceptors, name, serviceAccountName, template, additionalProperties, super.hashCode());
}
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (bindings != null && !bindings.isEmpty()) { sb.append("bindings:"); sb.append(bindings + ","); }
if (interceptors != null && !interceptors.isEmpty()) { sb.append("interceptors:"); sb.append(interceptors + ","); }
if (name != null) { sb.append("name:"); sb.append(name + ","); }
if (serviceAccountName != null) { sb.append("serviceAccountName:"); sb.append(serviceAccountName + ","); }
if (template != null) { sb.append("template:"); sb.append(template + ","); }
if (additionalProperties != null && !additionalProperties.isEmpty()) { sb.append("additionalProperties:"); sb.append(additionalProperties); }
sb.append("}");
return sb.toString();
}
public class BindingsNested extends TriggerSpecBindingFluent> implements Nested{
BindingsNested(int index,TriggerSpecBinding item) {
this.index = index;
this.builder = new TriggerSpecBindingBuilder(this, item);
}
TriggerSpecBindingBuilder builder;
int index;
public N and() {
return (N) TriggerSpecFluent.this.setToBindings(index,builder.build());
}
public N endBinding() {
return and();
}
}
public class InterceptorsNested extends TriggerInterceptorFluent> implements Nested{
InterceptorsNested(int index,TriggerInterceptor item) {
this.index = index;
this.builder = new TriggerInterceptorBuilder(this, item);
}
TriggerInterceptorBuilder builder;
int index;
public N and() {
return (N) TriggerSpecFluent.this.setToInterceptors(index,builder.build());
}
public N endInterceptor() {
return and();
}
}
public class TemplateNested extends TriggerSpecTemplateFluent> implements Nested{
TemplateNested(TriggerSpecTemplate item) {
this.builder = new TriggerSpecTemplateBuilder(this, item);
}
TriggerSpecTemplateBuilder builder;
public N and() {
return (N) TriggerSpecFluent.this.withTemplate(builder.build());
}
public N endTemplate() {
return and();
}
}
}