io.alauda.kubernetes.api.model.EndpointsFluentImpl Maven / Gradle / Ivy
package io.alauda.kubernetes.api.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.alauda.kubernetes.api.model.validators.CheckObjectMeta;
import java.lang.String;
import javax.validation.constraints.NotNull;
import io.alauda.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.List;
import java.lang.Boolean;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;
public class EndpointsFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements EndpointsFluent{
private String apiVersion;
private String kind;
private ObjectMetaBuilder metadata;
private List subsets = new ArrayList();
public EndpointsFluentImpl(){
}
public EndpointsFluentImpl(Endpoints instance){
this.withApiVersion(instance.getApiVersion());
this.withKind(instance.getKind());
this.withMetadata(instance.getMetadata());
this.withSubsets(instance.getSubsets());
}
public String getApiVersion(){
return this.apiVersion;
}
public A withApiVersion(String apiVersion){
this.apiVersion=apiVersion; return (A) this;
}
public Boolean hasApiVersion(){
return this.apiVersion!=null;
}
public String getKind(){
return this.kind;
}
public A withKind(String kind){
this.kind=kind; return (A) this;
}
public Boolean hasKind(){
return this.kind!=null;
}
/**
* This method has been deprecated, please use method buildMetadata instead.
*/
@Deprecated public ObjectMeta getMetadata(){
return this.metadata!=null?this.metadata.build():null;
}
public ObjectMeta buildMetadata(){
return this.metadata!=null?this.metadata.build():null;
}
public A withMetadata(ObjectMeta metadata){
_visitables.remove(this.metadata);
if (metadata!=null){ this.metadata= new ObjectMetaBuilder(metadata); _visitables.add(this.metadata);} return (A) this;
}
public Boolean hasMetadata(){
return this.metadata!=null;
}
public EndpointsFluent.MetadataNested withNewMetadata(){
return new MetadataNestedImpl();
}
public EndpointsFluent.MetadataNested withNewMetadataLike(ObjectMeta item){
return new MetadataNestedImpl(item);
}
public EndpointsFluent.MetadataNested editMetadata(){
return withNewMetadataLike(getMetadata());
}
public EndpointsFluent.MetadataNested editOrNewMetadata(){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ObjectMetaBuilder().build());
}
public EndpointsFluent.MetadataNested editOrNewMetadataLike(ObjectMeta item){
return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
}
public A addToSubsets(int index,EndpointSubset item){
EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.subsets.add(index >= 0 ? index : subsets.size(), builder); return (A)this;
}
public A setToSubsets(int index,EndpointSubset item){
EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);
if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
if (index < 0 || index >= subsets.size()) { subsets.add(builder); } else { subsets.set(index, builder);}
return (A)this;
}
public A addToSubsets(EndpointSubset... items){
for (EndpointSubset item : items) {EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);_visitables.add(builder);this.subsets.add(builder);} return (A)this;
}
public A addAllToSubsets(Collection items){
for (EndpointSubset item : items) {EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);_visitables.add(builder);this.subsets.add(builder);} return (A)this;
}
public A removeFromSubsets(EndpointSubset... items){
for (EndpointSubset item : items) {EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);_visitables.remove(builder);this.subsets.remove(builder);} return (A)this;
}
public A removeAllFromSubsets(Collection items){
for (EndpointSubset item : items) {EndpointSubsetBuilder builder = new EndpointSubsetBuilder(item);_visitables.remove(builder);this.subsets.remove(builder);} return (A)this;
}
/**
* This method has been deprecated, please use method buildSubsets instead.
*/
@Deprecated public List getSubsets(){
return build(subsets);
}
public List buildSubsets(){
return build(subsets);
}
public EndpointSubset buildSubset(int index){
return this.subsets.get(index).build();
}
public EndpointSubset buildFirstSubset(){
return this.subsets.get(0).build();
}
public EndpointSubset buildLastSubset(){
return this.subsets.get(subsets.size() - 1).build();
}
public EndpointSubset buildMatchingSubset(io.alauda.kubernetes.api.builder.Predicate predicate){
for (EndpointSubsetBuilder item: subsets) { if(predicate.apply(item)){return item.build();} } return null;
}
public A withSubsets(List subsets){
_visitables.removeAll(this.subsets);
this.subsets.clear();
if (subsets != null) {for (EndpointSubset item : subsets){this.addToSubsets(item);}} return (A) this;
}
public A withSubsets(EndpointSubset... subsets){
this.subsets.clear(); if (subsets != null) {for (EndpointSubset item :subsets){ this.addToSubsets(item);}} return (A) this;
}
public Boolean hasSubsets(){
return subsets!= null && !subsets.isEmpty();
}
public EndpointsFluent.SubsetsNested addNewSubset(){
return new SubsetsNestedImpl();
}
public EndpointsFluent.SubsetsNested addNewSubsetLike(EndpointSubset item){
return new SubsetsNestedImpl(-1, item);
}
public EndpointsFluent.SubsetsNested setNewSubsetLike(int index,EndpointSubset item){
return new SubsetsNestedImpl(index, item);
}
public EndpointsFluent.SubsetsNested editSubset(int index){
if (subsets.size() <= index) throw new RuntimeException("Can't edit subsets. Index exceeds size.");
return setNewSubsetLike(index, buildSubset(index));
}
public EndpointsFluent.SubsetsNested editFirstSubset(){
if (subsets.size() == 0) throw new RuntimeException("Can't edit first subsets. The list is empty.");
return setNewSubsetLike(0, buildSubset(0));
}
public EndpointsFluent.SubsetsNested editLastSubset(){
int index = subsets.size() - 1;
if (index < 0) throw new RuntimeException("Can't edit last subsets. The list is empty.");
return setNewSubsetLike(index, buildSubset(index));
}
public EndpointsFluent.SubsetsNested editMatchingSubset(io.alauda.kubernetes.api.builder.Predicate predicate){
int index = -1;
for (int i=0;i extends ObjectMetaFluentImpl> implements EndpointsFluent.MetadataNested,io.alauda.kubernetes.api.builder.Nested{
private final ObjectMetaBuilder builder;
MetadataNestedImpl(ObjectMeta item){
this.builder = new ObjectMetaBuilder(this, item);
}
MetadataNestedImpl(){
this.builder = new ObjectMetaBuilder(this);
}
public N and(){
return (N) EndpointsFluentImpl.this.withMetadata(builder.build());
}
public N endMetadata(){
return and();
}
}
public class SubsetsNestedImpl extends EndpointSubsetFluentImpl> implements EndpointsFluent.SubsetsNested,io.alauda.kubernetes.api.builder.Nested{
private final EndpointSubsetBuilder builder;
private final int index;
SubsetsNestedImpl(int index,EndpointSubset item){
this.index = index;
this.builder = new EndpointSubsetBuilder(this, item);
}
SubsetsNestedImpl(){
this.index = -1;
this.builder = new EndpointSubsetBuilder(this);
}
public N and(){
return (N) EndpointsFluentImpl.this.setToSubsets(index, builder.build());
}
public N endSubset(){
return and();
}
}
}