
io.kubernetes.client.models.V1LabelSelectorFluentImpl Maven / Gradle / Ivy
package io.kubernetes.client.models;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kubernetes.client.fluent.Predicate;
import java.util.LinkedHashMap;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;
import java.util.Map;
public class V1LabelSelectorFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1LabelSelectorFluent{
private List matchExpressions;
private Map matchLabels;
public V1LabelSelectorFluentImpl(){
}
public V1LabelSelectorFluentImpl(V1LabelSelector instance){
this.withMatchExpressions(instance.getMatchExpressions());
this.withMatchLabels(instance.getMatchLabels());
}
public A addToMatchExpressions(int index,V1LabelSelectorRequirement item){
if (this.matchExpressions == null) {this.matchExpressions = new ArrayList();}
V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.matchExpressions.add(index >= 0 ? index : matchExpressions.size(), builder); return (A)this;
}
public A setToMatchExpressions(int index,V1LabelSelectorRequirement item){
if (this.matchExpressions == null) {this.matchExpressions = new ArrayList();}
V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= matchExpressions.size()) { matchExpressions.add(builder); } else { matchExpressions.set(index, builder);}
return (A)this;
}
public A addToMatchExpressions(V1LabelSelectorRequirement... items){
if (this.matchExpressions == null) {this.matchExpressions = new ArrayList();}
for (V1LabelSelectorRequirement item : items) {V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);_visitables.add(builder);this.matchExpressions.add(builder);} return (A)this;
}
public A addAllToMatchExpressions(Collection items){
if (this.matchExpressions == null) {this.matchExpressions = new ArrayList();}
for (V1LabelSelectorRequirement item : items) {V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);_visitables.add(builder);this.matchExpressions.add(builder);} return (A)this;
}
public A removeFromMatchExpressions(V1LabelSelectorRequirement... items){
for (V1LabelSelectorRequirement item : items) {V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);_visitables.remove(builder);if (this.matchExpressions != null) {this.matchExpressions.remove(builder);}} return (A)this;
}
public A removeAllFromMatchExpressions(Collection items){
for (V1LabelSelectorRequirement item : items) {V1LabelSelectorRequirementBuilder builder = new V1LabelSelectorRequirementBuilder(item);_visitables.remove(builder);if (this.matchExpressions != null) {this.matchExpressions.remove(builder);}} return (A)this;
}
/**
* This method has been deprecated, please use method buildMatchExpressions instead.
*/
@Deprecated public List getMatchExpressions(){
return build(matchExpressions);
}
public List buildMatchExpressions(){
return build(matchExpressions);
}
public V1LabelSelectorRequirement buildMatchExpression(int index){
return this.matchExpressions.get(index).build();
}
public V1LabelSelectorRequirement buildFirstMatchExpression(){
return this.matchExpressions.get(0).build();
}
public V1LabelSelectorRequirement buildLastMatchExpression(){
return this.matchExpressions.get(matchExpressions.size() - 1).build();
}
public V1LabelSelectorRequirement buildMatchingMatchExpression(io.kubernetes.client.fluent.Predicate predicate){
for (V1LabelSelectorRequirementBuilder item: matchExpressions) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withMatchExpressions(List matchExpressions){
if (this.matchExpressions != null) { _visitables.removeAll(this.matchExpressions);}
if (matchExpressions != null) {this.matchExpressions = new ArrayList(); for (V1LabelSelectorRequirement item : matchExpressions){this.addToMatchExpressions(item);}} else { this.matchExpressions = null;} return (A) this;
}
public A withMatchExpressions(V1LabelSelectorRequirement... matchExpressions){
this.matchExpressions.clear(); if (matchExpressions != null) {for (V1LabelSelectorRequirement item :matchExpressions){ this.addToMatchExpressions(item);}} return (A) this;
}
public Boolean hasMatchExpressions(){
return matchExpressions != null && !matchExpressions.isEmpty();
}
public V1LabelSelectorFluent.MatchExpressionsNested addNewMatchExpression(){
return new MatchExpressionsNestedImpl();
}
public V1LabelSelectorFluent.MatchExpressionsNested addNewMatchExpressionLike(V1LabelSelectorRequirement item){
return new MatchExpressionsNestedImpl(-1, item);
}
public V1LabelSelectorFluent.MatchExpressionsNested setNewMatchExpressionLike(int index,V1LabelSelectorRequirement item){
return new MatchExpressionsNestedImpl(index, item);
}
public V1LabelSelectorFluent.MatchExpressionsNested editMatchExpression(int index){
if (matchExpressions.size() <= index) throw new RuntimeException("Can't edit matchExpressions. Index exceeds size.");
return setNewMatchExpressionLike(index, buildMatchExpression(index));
}
public V1LabelSelectorFluent.MatchExpressionsNested editFirstMatchExpression(){
if (matchExpressions.size() == 0) throw new RuntimeException("Can't edit first matchExpressions. The list is empty.");
return setNewMatchExpressionLike(0, buildMatchExpression(0));
}
public V1LabelSelectorFluent.MatchExpressionsNested editLastMatchExpression(){
int index = matchExpressions.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last matchExpressions. The list is empty.");
return setNewMatchExpressionLike(index, buildMatchExpression(index));
}
public V1LabelSelectorFluent.MatchExpressionsNested editMatchingMatchExpression(io.kubernetes.client.fluent.Predicate predicate){
int index = -1;
for (int i=0;i(); }
if(key != null && value != null) {this.matchLabels.put(key, value);} return (A)this;
}
public A addToMatchLabels(Map map){
if(this.matchLabels == null && map != null) { this.matchLabels = new LinkedHashMap(); }
if(map != null) { this.matchLabels.putAll(map);} return (A)this;
}
public A removeFromMatchLabels(String key){
if(this.matchLabels == null) { return (A) this; }
if(key != null && this.matchLabels != null) {this.matchLabels.remove(key);} return (A)this;
}
public A removeFromMatchLabels(Map map){
if(this.matchLabels == null) { return (A) this; }
if(map != null) { for(Object key : map.keySet()) {if (this.matchLabels != null){this.matchLabels.remove(key);}}} return (A)this;
}
public Map getMatchLabels(){
return this.matchLabels;
}
public A withMatchLabels(Map matchLabels){
if (matchLabels == null) { this.matchLabels = null;} else {this.matchLabels = new LinkedHashMap(matchLabels);} return (A) this;
}
public Boolean hasMatchLabels(){
return this.matchLabels != 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;
V1LabelSelectorFluentImpl that = (V1LabelSelectorFluentImpl) o;
if (matchExpressions != null ? !matchExpressions.equals(that.matchExpressions) :that.matchExpressions != null) return false;
if (matchLabels != null ? !matchLabels.equals(that.matchLabels) :that.matchLabels != null) return false;
return true;
}
public class MatchExpressionsNestedImpl extends V1LabelSelectorRequirementFluentImpl> implements V1LabelSelectorFluent.MatchExpressionsNested,io.kubernetes.client.fluent.Nested{
private final V1LabelSelectorRequirementBuilder builder;
private final int index;
MatchExpressionsNestedImpl(int index,V1LabelSelectorRequirement item){
this.index = index;
this.builder = new V1LabelSelectorRequirementBuilder(this, item);
}
MatchExpressionsNestedImpl(){
this.index = -1;
this.builder = new V1LabelSelectorRequirementBuilder(this);
}
public N and(){
return (N) V1LabelSelectorFluentImpl.this.setToMatchExpressions(index, builder.build());
}
public N endMatchExpression(){
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy