annotations.io.alauda.devops.api.model.ImageSourceFluentImpl Maven / Gradle / Ivy
package io.alauda.devops.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.alauda.kubernetes.api.builder.Predicate;
import io.alauda.kubernetes.api.model.ObjectReference;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import io.alauda.kubernetes.api.model.LocalObjectReferenceFluentImpl;
import java.util.List;
import java.lang.Boolean;
import io.alauda.kubernetes.api.model.ObjectReferenceFluentImpl;
import io.alauda.kubernetes.api.model.LocalObjectReferenceBuilder;
import javax.validation.Valid;
import io.alauda.kubernetes.api.model.ObjectReferenceBuilder;
import io.alauda.kubernetes.api.model.LocalObjectReference;
import java.util.Collection;
import java.lang.Object;
public class ImageSourceFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ImageSourceFluent{
private ObjectReferenceBuilder from;
private List paths = new ArrayList();
private LocalObjectReferenceBuilder pullSecret;
public ImageSourceFluentImpl(){
}
public ImageSourceFluentImpl(ImageSource instance){
this.withFrom(instance.getFrom());
this.withPaths(instance.getPaths());
this.withPullSecret(instance.getPullSecret());
}
/**
* This method has been deprecated, please use method buildFrom instead.
*/
@Deprecated public ObjectReference getFrom(){
return this.from!=null?this.from.build():null;
}
public ObjectReference buildFrom(){
return this.from!=null?this.from.build():null;
}
public A withFrom(ObjectReference from){
_visitables.remove(this.from);
if (from!=null){ this.from= new ObjectReferenceBuilder(from); _visitables.add(this.from);} return (A) this;
}
public Boolean hasFrom(){
return this.from!=null;
}
public ImageSourceFluent.FromNested withNewFrom(){
return new FromNestedImpl();
}
public ImageSourceFluent.FromNested withNewFromLike(ObjectReference item){
return new FromNestedImpl(item);
}
public ImageSourceFluent.FromNested editFrom(){
return withNewFromLike(getFrom());
}
public ImageSourceFluent.FromNested editOrNewFrom(){
return withNewFromLike(getFrom() != null ? getFrom(): new ObjectReferenceBuilder().build());
}
public ImageSourceFluent.FromNested editOrNewFromLike(ObjectReference item){
return withNewFromLike(getFrom() != null ? getFrom(): item);
}
public A addToPaths(int index,ImageSourcePath item){
ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.paths.add(index >= 0 ? index : paths.size(), builder); return (A)this;
}
public A setToPaths(int index,ImageSourcePath item){
ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= paths.size()) { paths.add(builder); } else { paths.set(index, builder);}
return (A)this;
}
public A addToPaths(ImageSourcePath... items){
for (ImageSourcePath item : items) {ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);_visitables.add(builder);this.paths.add(builder);} return (A)this;
}
public A addAllToPaths(Collection items){
for (ImageSourcePath item : items) {ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);_visitables.add(builder);this.paths.add(builder);} return (A)this;
}
public A removeFromPaths(ImageSourcePath... items){
for (ImageSourcePath item : items) {ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);_visitables.remove(builder);this.paths.remove(builder);} return (A)this;
}
public A removeAllFromPaths(Collection items){
for (ImageSourcePath item : items) {ImageSourcePathBuilder builder = new ImageSourcePathBuilder(item);_visitables.remove(builder);this.paths.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildPaths instead.
*/
@Deprecated public List getPaths(){
return build(paths);
}
public List buildPaths(){
return build(paths);
}
public ImageSourcePath buildPath(int index){
return this.paths.get(index).build();
}
public ImageSourcePath buildFirstPath(){
return this.paths.get(0).build();
}
public ImageSourcePath buildLastPath(){
return this.paths.get(paths.size() - 1).build();
}
public ImageSourcePath buildMatchingPath(io.alauda.kubernetes.api.builder.Predicate predicate){
for (ImageSourcePathBuilder item: paths) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withPaths(List paths){
_visitables.removeAll(this.paths);
this.paths.clear();
if (paths != null) {for (ImageSourcePath item : paths){this.addToPaths(item);}} return (A) this;
}
public A withPaths(ImageSourcePath... paths){
this.paths.clear(); if (paths != null) {for (ImageSourcePath item :paths){ this.addToPaths(item);}} return (A) this;
}
public Boolean hasPaths(){
return paths!= null && !paths.isEmpty();
}
public ImageSourceFluent.PathsNested addNewPath(){
return new PathsNestedImpl();
}
public ImageSourceFluent.PathsNested addNewPathLike(ImageSourcePath item){
return new PathsNestedImpl(-1, item);
}
public ImageSourceFluent.PathsNested setNewPathLike(int index,ImageSourcePath item){
return new PathsNestedImpl(index, item);
}
public ImageSourceFluent.PathsNested editPath(int index){
if (paths.size() <= index) throw new RuntimeException("Can't edit paths. Index exceeds size.");
return setNewPathLike(index, buildPath(index));
}
public ImageSourceFluent.PathsNested editFirstPath(){
if (paths.size() == 0) throw new RuntimeException("Can't edit first paths. The list is empty.");
return setNewPathLike(0, buildPath(0));
}
public ImageSourceFluent.PathsNested editLastPath(){
int index = paths.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last paths. The list is empty.");
return setNewPathLike(index, buildPath(index));
}
public ImageSourceFluent.PathsNested editMatchingPath(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewPullSecret(){
return new PullSecretNestedImpl();
}
public ImageSourceFluent.PullSecretNested withNewPullSecretLike(LocalObjectReference item){
return new PullSecretNestedImpl(item);
}
public ImageSourceFluent.PullSecretNested editPullSecret(){
return withNewPullSecretLike(getPullSecret());
}
public ImageSourceFluent.PullSecretNested editOrNewPullSecret(){
return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): new LocalObjectReferenceBuilder().build());
}
public ImageSourceFluent.PullSecretNested editOrNewPullSecretLike(LocalObjectReference item){
return withNewPullSecretLike(getPullSecret() != null ? getPullSecret(): item);
}
public A withNewPullSecret(String name){
return (A)withPullSecret(new LocalObjectReference(name));
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
ImageSourceFluentImpl that = (ImageSourceFluentImpl) o;
if (from != null ? !from.equals(that.from) :that.from != null) return false;
if (paths != null ? !paths.equals(that.paths) :that.paths != null) return false;
if (pullSecret != null ? !pullSecret.equals(that.pullSecret) :that.pullSecret != null) return false;
return true;
}
public class FromNestedImpl extends ObjectReferenceFluentImpl> implements ImageSourceFluent.FromNested,io.alauda.kubernetes.api.builder.Nested{
private final ObjectReferenceBuilder builder;
FromNestedImpl(ObjectReference item){
this.builder = new ObjectReferenceBuilder(this, item);
}
FromNestedImpl(){
this.builder = new ObjectReferenceBuilder(this);
}
public N and(){
return (N) ImageSourceFluentImpl.this.withFrom(builder.build());
}
public N endFrom(){
return and();
}
}
public class PathsNestedImpl extends ImageSourcePathFluentImpl> implements ImageSourceFluent.PathsNested,io.alauda.kubernetes.api.builder.Nested{
private final ImageSourcePathBuilder builder;
private final int index;
PathsNestedImpl(int index,ImageSourcePath item){
this.index = index;
this.builder = new ImageSourcePathBuilder(this, item);
}
PathsNestedImpl(){
this.index = -1;
this.builder = new ImageSourcePathBuilder(this);
}
public N and(){
return (N) ImageSourceFluentImpl.this.setToPaths(index, builder.build());
}
public N endPath(){
return and();
}
}
public class PullSecretNestedImpl extends LocalObjectReferenceFluentImpl> implements ImageSourceFluent.PullSecretNested,io.alauda.kubernetes.api.builder.Nested{
private final LocalObjectReferenceBuilder builder;
PullSecretNestedImpl(LocalObjectReference item){
this.builder = new LocalObjectReferenceBuilder(this, item);
}
PullSecretNestedImpl(){
this.builder = new LocalObjectReferenceBuilder(this);
}
public N and(){
return (N) ImageSourceFluentImpl.this.withPullSecret(builder.build());
}
public N endPullSecret(){
return and();
}
}
}