io.dekorate.halkyon.model.ComponentSpecFluentImpl Maven / Gradle / Ivy
package io.dekorate.halkyon.model;
import io.dekorate.deps.kubernetes.api.builder.VisitableBuilder;
import java.lang.StringBuilder;
import io.dekorate.deps.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.dekorate.deps.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.dekorate.deps.kubernetes.api.builder.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.StringBuffer;
import java.util.Collection;
import java.lang.Object;
public class ComponentSpecFluentImpl> extends BaseFluent implements ComponentSpecFluent{
private DeploymentMode deploymentMode;
private String runtime;
private String version;
private boolean exposeService;
private Integer port;
private StorageBuilder storage;
private List envs;
private BuildConfigBuilder buildConfig;
private CapabilitiesBuilder capabilities;
public ComponentSpecFluentImpl(){
}
public ComponentSpecFluentImpl(ComponentSpec instance){
this.withDeploymentMode(instance.getDeploymentMode());
this.withRuntime(instance.getRuntime());
this.withVersion(instance.getVersion());
this.withExposeService(instance.isExposeService());
this.withPort(instance.getPort());
this.withStorage(instance.getStorage());
this.withEnvs(instance.getEnvs());
this.withBuildConfig(instance.getBuildConfig());
this.withCapabilities(instance.getCapabilities());
}
public DeploymentMode getDeploymentMode(){
return this.deploymentMode;
}
public A withDeploymentMode(DeploymentMode deploymentMode){
this.deploymentMode=deploymentMode; return (A) this;
}
public Boolean hasDeploymentMode(){
return this.deploymentMode != null;
}
public String getRuntime(){
return this.runtime;
}
public A withRuntime(String runtime){
this.runtime=runtime; return (A) this;
}
public Boolean hasRuntime(){
return this.runtime != null;
}
public A withNewRuntime(String arg1){
return (A)withRuntime(new String(arg1));
}
public A withNewRuntime(StringBuilder arg1){
return (A)withRuntime(new String(arg1));
}
public A withNewRuntime(StringBuffer arg1){
return (A)withRuntime(new String(arg1));
}
public String getVersion(){
return this.version;
}
public A withVersion(String version){
this.version=version; return (A) this;
}
public Boolean hasVersion(){
return this.version != null;
}
public A withNewVersion(String arg1){
return (A)withVersion(new String(arg1));
}
public A withNewVersion(StringBuilder arg1){
return (A)withVersion(new String(arg1));
}
public A withNewVersion(StringBuffer arg1){
return (A)withVersion(new String(arg1));
}
public boolean isExposeService(){
return this.exposeService;
}
public A withExposeService(boolean exposeService){
this.exposeService=exposeService; return (A) this;
}
public Boolean hasExposeService(){
return true;
}
public Integer getPort(){
return this.port;
}
public A withPort(Integer port){
this.port=port; return (A) this;
}
public Boolean hasPort(){
return this.port != null;
}
/**
* This method has been deprecated, please use method buildStorage instead.
* @return The buildable object.
*/
@Deprecated public Storage getStorage(){
return this.storage!=null?this.storage.build():null;
}
public Storage buildStorage(){
return this.storage!=null?this.storage.build():null;
}
public A withStorage(Storage storage){
_visitables.get("storage").remove(this.storage);
if (storage!=null){ this.storage= new StorageBuilder(storage); _visitables.get("storage").add(this.storage);} return (A) this;
}
public Boolean hasStorage(){
return this.storage != null;
}
public A withNewStorage(String name,String capacity,String mode){
return (A)withStorage(new Storage(name, capacity, mode));
}
public ComponentSpecFluent.StorageNested withNewStorage(){
return new StorageNestedImpl();
}
public ComponentSpecFluent.StorageNested withNewStorageLike(Storage item){
return new StorageNestedImpl(item);
}
public ComponentSpecFluent.StorageNested editStorage(){
return withNewStorageLike(getStorage());
}
public ComponentSpecFluent.StorageNested editOrNewStorage(){
return withNewStorageLike(getStorage() != null ? getStorage(): new StorageBuilder().build());
}
public ComponentSpecFluent.StorageNested editOrNewStorageLike(Storage item){
return withNewStorageLike(getStorage() != null ? getStorage(): item);
}
public A withEnvs(Env... envs){
if (this.envs != null) {this.envs.clear();}
if (envs != null) {for (Env item :envs){ this.addToEnvs(item);}} return (A) this;
}
/**
* This method has been deprecated, please use method buildEnvs instead.
*/
@Deprecated public Env[] getEnvs(){
int size = envs != null ? envs.size() : 0;
Env[] result = new Env[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends Env,?> builder : envs) {
result[index++]=builder.build();
}
return result;
}
public Env[] buildEnvs(){
int size = envs != null ? envs.size() : 0;
Env[] result = new Env[size];
if (size == 0) {
return result;
}
int index = 0;
for (VisitableBuilder extends Env,?> builder : envs) {
result[index++]=builder.build();
}
return result;
}
public Env buildEnv(int index){
return this.envs.get(index).build();
}
public Env buildFirstEnv(){
return this.envs.get(0).build();
}
public Env buildLastEnv(){
return this.envs.get(envs.size() - 1).build();
}
public Env buildMatchingEnv(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
for (EnvBuilder item: envs) { if(predicate.apply(item)){ return item.build();} } return null;
}
public Boolean hasMatchingEnv(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
for (EnvBuilder item: envs) { if(predicate.apply(item)){ return true;} } return false;
}
public A addToEnvs(int index,Env item){
if (this.envs == null) {this.envs = new ArrayList();}
EnvBuilder builder = new EnvBuilder(item);_visitables.get("envs").add(index >= 0 ? index : _visitables.get("envs").size(), builder);this.envs.add(index >= 0 ? index : envs.size(), builder); return (A)this;
}
public A setToEnvs(int index,Env item){
if (this.envs == null) {this.envs = new ArrayList();}
EnvBuilder builder = new EnvBuilder(item);
if (index < 0 || index >= _visitables.get("envs").size()) { _visitables.get("envs").add(builder); } else { _visitables.get("envs").set(index, builder);}
if (index < 0 || index >= envs.size()) { envs.add(builder); } else { envs.set(index, builder);}
return (A)this;
}
public A addToEnvs(Env... items){
if (this.envs == null) {this.envs = new ArrayList();}
for (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("envs").add(builder);this.envs.add(builder);} return (A)this;
}
public A addAllToEnvs(Collection items){
if (this.envs == null) {this.envs = new ArrayList();}
for (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("envs").add(builder);this.envs.add(builder);} return (A)this;
}
public A removeFromEnvs(Env... items){
for (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("envs").remove(builder);if (this.envs != null) {this.envs.remove(builder);}} return (A)this;
}
public A removeAllFromEnvs(Collection items){
for (Env item : items) {EnvBuilder builder = new EnvBuilder(item);_visitables.get("envs").remove(builder);if (this.envs != null) {this.envs.remove(builder);}} return (A)this;
}
public A removeMatchingFromEnvs(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
if (envs == null) return (A) this;
final Iterator each = envs.iterator();
final List visitables = _visitables.get("envs");
while (each.hasNext()) {
EnvBuilder builder = each.next();
if (predicate.apply(builder)) {
visitables.remove(builder);
each.remove();
}
}
return (A)this;
}
public Boolean hasEnvs(){
return envs != null && !envs.isEmpty();
}
public A addNewEnv(String name,String value){
return (A)addToEnvs(new Env(name, value));
}
public ComponentSpecFluent.EnvsNested addNewEnv(){
return new EnvsNestedImpl();
}
public ComponentSpecFluent.EnvsNested addNewEnvLike(Env item){
return new EnvsNestedImpl(-1, item);
}
public ComponentSpecFluent.EnvsNested setNewEnvLike(int index,Env item){
return new EnvsNestedImpl(index, item);
}
public ComponentSpecFluent.EnvsNested editEnv(int index){
if (envs.size() <= index) throw new RuntimeException("Can't edit envs. Index exceeds size.");
return setNewEnvLike(index, buildEnv(index));
}
public ComponentSpecFluent.EnvsNested editFirstEnv(){
if (envs.size() == 0) throw new RuntimeException("Can't edit first envs. The list is empty.");
return setNewEnvLike(0, buildEnv(0));
}
public ComponentSpecFluent.EnvsNested editLastEnv(){
int index = envs.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last envs. The list is empty.");
return setNewEnvLike(index, buildEnv(index));
}
public ComponentSpecFluent.EnvsNested editMatchingEnv(io.dekorate.deps.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i withNewBuildConfig(){
return new BuildConfigNestedImpl();
}
public ComponentSpecFluent.BuildConfigNested withNewBuildConfigLike(BuildConfig item){
return new BuildConfigNestedImpl(item);
}
public ComponentSpecFluent.BuildConfigNested editBuildConfig(){
return withNewBuildConfigLike(getBuildConfig());
}
public ComponentSpecFluent.BuildConfigNested editOrNewBuildConfig(){
return withNewBuildConfigLike(getBuildConfig() != null ? getBuildConfig(): new BuildConfigBuilder().build());
}
public ComponentSpecFluent.BuildConfigNested editOrNewBuildConfigLike(BuildConfig item){
return withNewBuildConfigLike(getBuildConfig() != null ? getBuildConfig(): item);
}
/**
* This method has been deprecated, please use method buildCapabilities instead.
* @return The buildable object.
*/
@Deprecated public Capabilities getCapabilities(){
return this.capabilities!=null?this.capabilities.build():null;
}
public Capabilities buildCapabilities(){
return this.capabilities!=null?this.capabilities.build():null;
}
public A withCapabilities(Capabilities capabilities){
_visitables.get("capabilities").remove(this.capabilities);
if (capabilities!=null){ this.capabilities= new CapabilitiesBuilder(capabilities); _visitables.get("capabilities").add(this.capabilities);} return (A) this;
}
public Boolean hasCapabilities(){
return this.capabilities != null;
}
public ComponentSpecFluent.CapabilitiesNested withNewCapabilities(){
return new CapabilitiesNestedImpl();
}
public ComponentSpecFluent.CapabilitiesNested withNewCapabilitiesLike(Capabilities item){
return new CapabilitiesNestedImpl(item);
}
public ComponentSpecFluent.CapabilitiesNested editCapabilities(){
return withNewCapabilitiesLike(getCapabilities());
}
public ComponentSpecFluent.CapabilitiesNested editOrNewCapabilities(){
return withNewCapabilitiesLike(getCapabilities() != null ? getCapabilities(): new CapabilitiesBuilder().build());
}
public ComponentSpecFluent.CapabilitiesNested editOrNewCapabilitiesLike(Capabilities item){
return withNewCapabilitiesLike(getCapabilities() != null ? getCapabilities(): item);
}
public boolean equals(Object o){
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ComponentSpecFluentImpl that = (ComponentSpecFluentImpl) o;
if (deploymentMode != null ? !deploymentMode.equals(that.deploymentMode) :that.deploymentMode != null) return false;
if (runtime != null ? !runtime.equals(that.runtime) :that.runtime != null) return false;
if (version != null ? !version.equals(that.version) :that.version != null) return false;
if (exposeService != that.exposeService) return false;
if (port != null ? !port.equals(that.port) :that.port != null) return false;
if (storage != null ? !storage.equals(that.storage) :that.storage != null) return false;
if (envs != null ? !envs.equals(that.envs) :that.envs != null) return false;
if (buildConfig != null ? !buildConfig.equals(that.buildConfig) :that.buildConfig != null) return false;
if (capabilities != null ? !capabilities.equals(that.capabilities) :that.capabilities != null) return false;
return true;
}
public class StorageNestedImpl extends StorageFluentImpl> implements ComponentSpecFluent.StorageNested,io.dekorate.deps.kubernetes.api.builder.Nested{
private final StorageBuilder builder;
StorageNestedImpl(Storage item){
this.builder = new StorageBuilder(this, item);
}
StorageNestedImpl(){
this.builder = new StorageBuilder(this);
}
public N and(){
return (N) ComponentSpecFluentImpl.this.withStorage(builder.build());
}
public N endStorage(){
return and();
}
}
public class EnvsNestedImpl extends EnvFluentImpl> implements ComponentSpecFluent.EnvsNested,io.dekorate.deps.kubernetes.api.builder.Nested{
private final EnvBuilder builder;
private final int index;
EnvsNestedImpl(int index,Env item){
this.index = index;
this.builder = new EnvBuilder(this, item);
}
EnvsNestedImpl(){
this.index = -1;
this.builder = new EnvBuilder(this);
}
public N and(){
return (N) ComponentSpecFluentImpl.this.setToEnvs(index,builder.build());
}
public N endEnv(){
return and();
}
}
public class BuildConfigNestedImpl extends BuildConfigFluentImpl> implements ComponentSpecFluent.BuildConfigNested,io.dekorate.deps.kubernetes.api.builder.Nested{
private final BuildConfigBuilder builder;
BuildConfigNestedImpl(BuildConfig item){
this.builder = new BuildConfigBuilder(this, item);
}
BuildConfigNestedImpl(){
this.builder = new BuildConfigBuilder(this);
}
public N and(){
return (N) ComponentSpecFluentImpl.this.withBuildConfig(builder.build());
}
public N endBuildConfig(){
return and();
}
}
public class CapabilitiesNestedImpl extends CapabilitiesFluentImpl> implements ComponentSpecFluent.CapabilitiesNested,io.dekorate.deps.kubernetes.api.builder.Nested{
private final CapabilitiesBuilder builder;
CapabilitiesNestedImpl(Capabilities item){
this.builder = new CapabilitiesBuilder(this, item);
}
CapabilitiesNestedImpl(){
this.builder = new CapabilitiesBuilder(this);
}
public N and(){
return (N) ComponentSpecFluentImpl.this.withCapabilities(builder.build());
}
public N endCapabilities(){
return and();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy