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

annotations.io.alauda.kubernetes.api.model.extensions.HTTPIngressRuleValueFluentImpl 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 io.alauda.kubernetes.api.builder.Nested;
import java.util.ArrayList;
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 HTTPIngressRuleValueFluentImpl> extends io.alauda.kubernetes.api.builder.BaseFluent implements HTTPIngressRuleValueFluent{

    private List paths =  new ArrayList();

    public HTTPIngressRuleValueFluentImpl(){
    }
    public HTTPIngressRuleValueFluentImpl(HTTPIngressRuleValue instance){
            this.withPaths(instance.getPaths()); 
    }

    public A addToPaths(int index,HTTPIngressPath item){
            HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(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,HTTPIngressPath item){
            HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(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(HTTPIngressPath... items){
            for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.add(builder);this.paths.add(builder);} return (A)this;
    }

    public A addAllToPaths(Collection items){
            for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.add(builder);this.paths.add(builder);} return (A)this;
    }

    public A removeFromPaths(HTTPIngressPath... items){
            for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(item);_visitables.remove(builder);this.paths.remove(builder);} return (A)this;
    }

    public A removeAllFromPaths(Collection items){
            for (HTTPIngressPath item : items) {HTTPIngressPathBuilder builder = new HTTPIngressPathBuilder(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 HTTPIngressPath buildPath(int index){
            return this.paths.get(index).build();
    }

    public HTTPIngressPath buildFirstPath(){
            return this.paths.get(0).build();
    }

    public HTTPIngressPath buildLastPath(){
            return this.paths.get(paths.size() - 1).build();
    }

    public HTTPIngressPath buildMatchingPath(io.alauda.kubernetes.api.builder.Predicate predicate){
            for (HTTPIngressPathBuilder 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 (HTTPIngressPath item : paths){this.addToPaths(item);}} return (A) this;
    }

    public A withPaths(HTTPIngressPath... paths){
            this.paths.clear(); if (paths != null) {for (HTTPIngressPath item :paths){ this.addToPaths(item);}} return (A) this;
    }

    public Boolean hasPaths(){
            return paths!= null && !paths.isEmpty();
    }

    public HTTPIngressRuleValueFluent.PathsNested addNewPath(){
            return new PathsNestedImpl();
    }

    public HTTPIngressRuleValueFluent.PathsNested addNewPathLike(HTTPIngressPath item){
            return new PathsNestedImpl(-1, item);
    }

    public HTTPIngressRuleValueFluent.PathsNested setNewPathLike(int index,HTTPIngressPath item){
            return new PathsNestedImpl(index, item);
    }

    public HTTPIngressRuleValueFluent.PathsNested editPath(int index){
            if (paths.size() <= index) throw new RuntimeException("Can't edit paths. Index exceeds size.");
            return setNewPathLike(index, buildPath(index));
    }

    public HTTPIngressRuleValueFluent.PathsNested editFirstPath(){
            if (paths.size() == 0) throw new RuntimeException("Can't edit first paths. The list is empty.");
            return setNewPathLike(0, buildPath(0));
    }

    public HTTPIngressRuleValueFluent.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 HTTPIngressRuleValueFluent.PathsNested editMatchingPath(io.alauda.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends HTTPIngressPathFluentImpl> implements HTTPIngressRuleValueFluent.PathsNested,io.alauda.kubernetes.api.builder.Nested{

            private final HTTPIngressPathBuilder builder;
        private final int index;
    
            PathsNestedImpl(int index,HTTPIngressPath item){
                    this.index = index;
                    this.builder = new HTTPIngressPathBuilder(this, item);
            }
            PathsNestedImpl(){
                    this.index = -1;
                    this.builder = new HTTPIngressPathBuilder(this);
            }
    
    public N and(){
            return (N) HTTPIngressRuleValueFluentImpl.this.setToPaths(index, builder.build());
    }
    public N endPath(){
            return and();
    }

}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy