All Downloads are FREE. Search and download functionalities are using the official Maven repository.

annotations.io.alauda.kubernetes.api.model.extensions.ThirdPartyResourceFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
package io.alauda.kubernetes.api.model.extensions;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
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 io.alauda.kubernetes.api.model.ObjectMeta;
import io.alauda.kubernetes.api.model.ObjectMetaFluentImpl;
import io.alauda.kubernetes.api.model.ObjectMetaBuilder;
import javax.validation.Valid;
import java.util.Collection;
import java.lang.Object;

public class ThirdPartyResourceFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ThirdPartyResourceFluent{

    private String apiVersion;
    private String description;
    private String kind;
    private ObjectMetaBuilder metadata;
    private List versions =  new ArrayList();

    public ThirdPartyResourceFluentImpl(){
    }
    public ThirdPartyResourceFluentImpl(ThirdPartyResource instance){
            this.withApiVersion(instance.getApiVersion()); 
            this.withDescription(instance.getDescription()); 
            this.withKind(instance.getKind()); 
            this.withMetadata(instance.getMetadata()); 
            this.withVersions(instance.getVersions()); 
    }

    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 getDescription(){
            return this.description;
    }

    public A withDescription(String description){
            this.description=description; return (A) this;
    }

    public Boolean hasDescription(){
            return this.description!=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 ThirdPartyResourceFluent.MetadataNested withNewMetadata(){
            return new MetadataNestedImpl();
    }

    public ThirdPartyResourceFluent.MetadataNested withNewMetadataLike(ObjectMeta item){
            return new MetadataNestedImpl(item);
    }

    public ThirdPartyResourceFluent.MetadataNested editMetadata(){
            return withNewMetadataLike(getMetadata());
    }

    public ThirdPartyResourceFluent.MetadataNested editOrNewMetadata(){
            return withNewMetadataLike(getMetadata() != null ? getMetadata(): new ObjectMetaBuilder().build());
    }

    public ThirdPartyResourceFluent.MetadataNested editOrNewMetadataLike(ObjectMeta item){
            return withNewMetadataLike(getMetadata() != null ? getMetadata(): item);
    }

    public A addToVersions(int index,APIVersion item){
            APIVersionBuilder builder = new APIVersionBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.versions.add(index >= 0 ? index : versions.size(), builder); return (A)this;
    }

    public A setToVersions(int index,APIVersion item){
            APIVersionBuilder builder = new APIVersionBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= versions.size()) { versions.add(builder); } else { versions.set(index, builder);}
             return (A)this;
    }

    public A addToVersions(APIVersion... items){
            for (APIVersion item : items) {APIVersionBuilder builder = new APIVersionBuilder(item);_visitables.add(builder);this.versions.add(builder);} return (A)this;
    }

    public A addAllToVersions(Collection items){
            for (APIVersion item : items) {APIVersionBuilder builder = new APIVersionBuilder(item);_visitables.add(builder);this.versions.add(builder);} return (A)this;
    }

    public A removeFromVersions(APIVersion... items){
            for (APIVersion item : items) {APIVersionBuilder builder = new APIVersionBuilder(item);_visitables.remove(builder);this.versions.remove(builder);} return (A)this;
    }

    public A removeAllFromVersions(Collection items){
            for (APIVersion item : items) {APIVersionBuilder builder = new APIVersionBuilder(item);_visitables.remove(builder);this.versions.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildVersions instead.
 */
@Deprecated public List getVersions(){
            return build(versions);
    }

    public List buildVersions(){
            return build(versions);
    }

    public APIVersion buildVersion(int index){
            return this.versions.get(index).build();
    }

    public APIVersion buildFirstVersion(){
            return this.versions.get(0).build();
    }

    public APIVersion buildLastVersion(){
            return this.versions.get(versions.size() - 1).build();
    }

    public APIVersion buildMatchingVersion(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (APIVersionBuilder item: versions) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withVersions(List versions){
            _visitables.removeAll(this.versions);
            this.versions.clear();
            if (versions != null) {for (APIVersion item : versions){this.addToVersions(item);}} return (A) this;
    }

    public A withVersions(APIVersion... versions){
            this.versions.clear(); if (versions != null) {for (APIVersion item :versions){ this.addToVersions(item);}} return (A) this;
    }

    public Boolean hasVersions(){
            return versions!= null && !versions.isEmpty();
    }

    public ThirdPartyResourceFluent.VersionsNested addNewVersion(){
            return new VersionsNestedImpl();
    }

    public ThirdPartyResourceFluent.VersionsNested addNewVersionLike(APIVersion item){
            return new VersionsNestedImpl(-1, item);
    }

    public ThirdPartyResourceFluent.VersionsNested setNewVersionLike(int index,APIVersion item){
            return new VersionsNestedImpl(index, item);
    }

    public ThirdPartyResourceFluent.VersionsNested editVersion(int index){
            if (versions.size() <= index) throw new RuntimeException("Can't edit versions. Index exceeds size.");
            return setNewVersionLike(index, buildVersion(index));
    }

    public ThirdPartyResourceFluent.VersionsNested editFirstVersion(){
            if (versions.size() == 0) throw new RuntimeException("Can't edit first versions. The list is empty.");
            return setNewVersionLike(0, buildVersion(0));
    }

    public ThirdPartyResourceFluent.VersionsNested editLastVersion(){
            int index = versions.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last versions. The list is empty.");
            return setNewVersionLike(index, buildVersion(index));
    }

    public ThirdPartyResourceFluent.VersionsNested editMatchingVersion(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends ObjectMetaFluentImpl> implements ThirdPartyResourceFluent.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) ThirdPartyResourceFluentImpl.this.withMetadata(builder.build());
    }
    public N endMetadata(){
            return and();
    }

}
    public class VersionsNestedImpl extends APIVersionFluentImpl> implements ThirdPartyResourceFluent.VersionsNested,io.alauda.kubernetes.api.builder.Nested{

            private final APIVersionBuilder builder;
        private final int index;
    
            VersionsNestedImpl(int index,APIVersion item){
                    this.index = index;
                    this.builder = new APIVersionBuilder(this, item);
            }
            VersionsNestedImpl(){
                    this.index = -1;
                    this.builder = new APIVersionBuilder(this);
            }
    
    public N and(){
            return (N) ThirdPartyResourceFluentImpl.this.setToVersions(index, builder.build());
    }
    public N endVersion(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy