io.github.microcks.operator.api.secret.v1alpha1.SecretSourceSpecFluent Maven / Gradle / Ivy
package io.github.microcks.operator.api.secret.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.function.Predicate;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
/**
* Generated
*/
@SuppressWarnings("unchecked")
public class SecretSourceSpecFluent> extends BaseFluent{
public SecretSourceSpecFluent() {
}
public SecretSourceSpecFluent(SecretSourceSpec instance) {
this.copyInstance(instance);
}
private ArrayList secrets;
protected void copyInstance(SecretSourceSpec instance) {
instance = (instance != null ? instance : new SecretSourceSpec());
if (instance != null) {
this.withSecrets(instance.getSecrets());
}
}
public A addToSecrets(int index,SecretSpec item) {
if (this.secrets == null) {this.secrets = new ArrayList();}
SecretSpecBuilder builder = new SecretSpecBuilder(item);
if (index < 0 || index >= secrets.size()) { _visitables.get("secrets").add(builder); secrets.add(builder); } else { _visitables.get("secrets").add(index, builder); secrets.add(index, builder);}
return (A)this;
}
public A setToSecrets(int index,SecretSpec item) {
if (this.secrets == null) {this.secrets = new ArrayList();}
SecretSpecBuilder builder = new SecretSpecBuilder(item);
if (index < 0 || index >= secrets.size()) { _visitables.get("secrets").add(builder); secrets.add(builder); } else { _visitables.get("secrets").set(index, builder); secrets.set(index, builder);}
return (A)this;
}
public A addToSecrets(io.github.microcks.operator.api.secret.v1alpha1.SecretSpec... items) {
if (this.secrets == null) {this.secrets = new ArrayList();}
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.get("secrets").add(builder);this.secrets.add(builder);} return (A)this;
}
public A addAllToSecrets(Collection items) {
if (this.secrets == null) {this.secrets = new ArrayList();}
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.get("secrets").add(builder);this.secrets.add(builder);} return (A)this;
}
public A removeFromSecrets(io.github.microcks.operator.api.secret.v1alpha1.SecretSpec... items) {
if (this.secrets == null) return (A)this;
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.get("secrets").remove(builder); this.secrets.remove(builder);} return (A)this;
}
public A removeAllFromSecrets(Collection items) {
if (this.secrets == null) return (A)this;
for (SecretSpec item : items) {SecretSpecBuilder builder = new SecretSpecBuilder(item);_visitables.get("secrets").remove(builder); this.secrets.remove(builder);} return (A)this;
}
public A removeMatchingFromSecrets(Predicate predicate) {
if (secrets == null) return (A) this;
final Iterator each = secrets.iterator();
final List visitables = _visitables.get("secrets");
while (each.hasNext()) {
SecretSpecBuilder builder = each.next();
if (predicate.test(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public List buildSecrets() {
return this.secrets != null ? build(secrets) : null;
}
public SecretSpec buildSecret(int index) {
return this.secrets.get(index).build();
}
public SecretSpec buildFirstSecret() {
return this.secrets.get(0).build();
}
public SecretSpec buildLastSecret() {
return this.secrets.get(secrets.size() - 1).build();
}
public SecretSpec buildMatchingSecret(Predicate predicate) {
for (SecretSpecBuilder item : secrets) {
if (predicate.test(item)) {
return item.build();
}
}
return null;
}
public boolean hasMatchingSecret(Predicate predicate) {
for (SecretSpecBuilder item : secrets) {
if (predicate.test(item)) {
return true;
}
}
return false;
}
public A withSecrets(List secrets) {
if (this.secrets != null) {
this._visitables.get("secrets").clear();
}
if (secrets != null) {
this.secrets = new ArrayList();
for (SecretSpec item : secrets) {
this.addToSecrets(item);
}
} else {
this.secrets = null;
}
return (A) this;
}
public A withSecrets(io.github.microcks.operator.api.secret.v1alpha1.SecretSpec... secrets) {
if (this.secrets != null) {
this.secrets.clear();
_visitables.remove("secrets");
}
if (secrets != null) {
for (SecretSpec item : secrets) {
this.addToSecrets(item);
}
}
return (A) this;
}
public boolean hasSecrets() {
return this.secrets != null && !this.secrets.isEmpty();
}
public SecretsNested addNewSecret() {
return new SecretsNested(-1, null);
}
public SecretsNested addNewSecretLike(SecretSpec item) {
return new SecretsNested(-1, item);
}
public SecretsNested setNewSecretLike(int index,SecretSpec item) {
return new SecretsNested(index, item);
}
public SecretsNested editSecret(int index) {
if (secrets.size() <= index) throw new RuntimeException("Can't edit secrets. Index exceeds size.");
return setNewSecretLike(index, buildSecret(index));
}
public SecretsNested editFirstSecret() {
if (secrets.size() == 0) throw new RuntimeException("Can't edit first secrets. The list is empty.");
return setNewSecretLike(0, buildSecret(0));
}
public SecretsNested editLastSecret() {
int index = secrets.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last secrets. The list is empty.");
return setNewSecretLike(index, buildSecret(index));
}
public SecretsNested editMatchingSecret(Predicate predicate) {
int index = -1;
for (int i=0;i extends SecretSpecFluent> implements Nested{
SecretsNested(int index,SecretSpec item) {
this.index = index;
this.builder = new SecretSpecBuilder(this, item);
}
SecretSpecBuilder builder;
int index;
public N and() {
return (N) SecretSourceSpecFluent.this.setToSecrets(index,builder.build());
}
public N endSecret() {
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy