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

annotations.io.alauda.kubernetes.api.model.ProjectSpecFluentImpl Maven / Gradle / Ivy

There is a newer version: 0.2.12
Show newest version
package io.alauda.kubernetes.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 java.lang.Deprecated;
import javax.validation.Valid;
import io.alauda.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class ProjectSpecFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements ProjectSpecFluent{

    private List namespaces =  new ArrayList();

    public ProjectSpecFluentImpl(){
    }
    public ProjectSpecFluentImpl(ProjectSpec instance){
            this.withNamespaces(instance.getNamespaces()); 
    }

    public A addToNamespaces(int index,ProjectNamespace item){
            ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.namespaces.add(index >= 0 ? index : namespaces.size(), builder); return (A)this;
    }

    public A setToNamespaces(int index,ProjectNamespace item){
            ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= namespaces.size()) { namespaces.add(builder); } else { namespaces.set(index, builder);}
             return (A)this;
    }

    public A addToNamespaces(ProjectNamespace... items){
            for (ProjectNamespace item : items) {ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);_visitables.add(builder);this.namespaces.add(builder);} return (A)this;
    }

    public A addAllToNamespaces(Collection items){
            for (ProjectNamespace item : items) {ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);_visitables.add(builder);this.namespaces.add(builder);} return (A)this;
    }

    public A removeFromNamespaces(ProjectNamespace... items){
            for (ProjectNamespace item : items) {ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);_visitables.remove(builder);this.namespaces.remove(builder);} return (A)this;
    }

    public A removeAllFromNamespaces(Collection items){
            for (ProjectNamespace item : items) {ProjectNamespaceBuilder builder = new ProjectNamespaceBuilder(item);_visitables.remove(builder);this.namespaces.remove(builder);} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildNamespaces instead.
 */
@Deprecated public List getNamespaces(){
            return build(namespaces);
    }

    public List buildNamespaces(){
            return build(namespaces);
    }

    public ProjectNamespace buildNamespace(int index){
            return this.namespaces.get(index).build();
    }

    public ProjectNamespace buildFirstNamespace(){
            return this.namespaces.get(0).build();
    }

    public ProjectNamespace buildLastNamespace(){
            return this.namespaces.get(namespaces.size() - 1).build();
    }

    public ProjectNamespace buildMatchingNamespace(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (ProjectNamespaceBuilder item: namespaces) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withNamespaces(List namespaces){
            _visitables.removeAll(this.namespaces);
            this.namespaces.clear();
            if (namespaces != null) {for (ProjectNamespace item : namespaces){this.addToNamespaces(item);}} return (A) this;
    }

    public A withNamespaces(ProjectNamespace... namespaces){
            this.namespaces.clear(); if (namespaces != null) {for (ProjectNamespace item :namespaces){ this.addToNamespaces(item);}} return (A) this;
    }

    public Boolean hasNamespaces(){
            return namespaces!= null && !namespaces.isEmpty();
    }

    public ProjectSpecFluent.NamespacesNested addNewNamespace(){
            return new NamespacesNestedImpl();
    }

    public ProjectSpecFluent.NamespacesNested addNewNamespaceLike(ProjectNamespace item){
            return new NamespacesNestedImpl(-1, item);
    }

    public ProjectSpecFluent.NamespacesNested setNewNamespaceLike(int index,ProjectNamespace item){
            return new NamespacesNestedImpl(index, item);
    }

    public ProjectSpecFluent.NamespacesNested editNamespace(int index){
            if (namespaces.size() <= index) throw new RuntimeException("Can't edit namespaces. Index exceeds size.");
            return setNewNamespaceLike(index, buildNamespace(index));
    }

    public ProjectSpecFluent.NamespacesNested editFirstNamespace(){
            if (namespaces.size() == 0) throw new RuntimeException("Can't edit first namespaces. The list is empty.");
            return setNewNamespaceLike(0, buildNamespace(0));
    }

    public ProjectSpecFluent.NamespacesNested editLastNamespace(){
            int index = namespaces.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last namespaces. The list is empty.");
            return setNewNamespaceLike(index, buildNamespace(index));
    }

    public ProjectSpecFluent.NamespacesNested editMatchingNamespace(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends ProjectNamespaceFluentImpl> implements ProjectSpecFluent.NamespacesNested,io.alauda.kubernetes.api.builder.Nested{

            private final ProjectNamespaceBuilder builder;
        private final int index;
    
            NamespacesNestedImpl(int index,ProjectNamespace item){
                    this.index = index;
                    this.builder = new ProjectNamespaceBuilder(this, item);
            }
            NamespacesNestedImpl(){
                    this.index = -1;
                    this.builder = new ProjectNamespaceBuilder(this);
            }
    
    public N and(){
            return (N) ProjectSpecFluentImpl.this.setToNamespaces(index, builder.build());
    }
    public N endNamespace(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy