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

io.kubernetes.client.openapi.models.V1beta1EndpointSliceFluentImpl Maven / Gradle / Ivy

There is a newer version: 22.0.0
Show newest version
package io.kubernetes.client.openapi.models;

import io.kubernetes.client.fluent.VisitableBuilder;
import java.lang.StringBuilder;
import com.google.gson.annotations.SerializedName;
import io.kubernetes.client.fluent.Nested;
import java.util.ArrayList;
import java.lang.String;
import io.kubernetes.client.fluent.Predicate;
import java.lang.Deprecated;
import io.kubernetes.client.fluent.BaseFluent;
import java.util.Iterator;
import java.util.List;
import java.lang.Boolean;
import java.lang.StringBuffer;
import java.util.Collection;
import java.lang.Object;

public class V1beta1EndpointSliceFluentImpl> extends io.kubernetes.client.fluent.BaseFluent implements V1beta1EndpointSliceFluent {

    private String addressType;
    private String apiVersion;
    private List endpoints;
    private String kind;
    private V1ObjectMetaBuilder metadata;
    private List ports;

    public V1beta1EndpointSliceFluentImpl() { 
    }


    public V1beta1EndpointSliceFluentImpl(V1beta1EndpointSlice instance) { 
        this.withAddressType(instance.getAddressType());

        this.withApiVersion(instance.getApiVersion());

        this.withEndpoints(instance.getEndpoints());

        this.withKind(instance.getKind());

        this.withMetadata(instance.getMetadata());

        this.withPorts(instance.getPorts());

    }


    public String getAddressType() {
        return this.addressType;
    }

    public A withAddressType(String addressType) {
        this.addressType=addressType; return (A) this;
    }

    public Boolean hasAddressType() {
        return this.addressType != null;
    }

    public A withNewAddressType(String arg1) {
        return (A)withAddressType(new String(arg1));
    }

    public A withNewAddressType(StringBuilder arg1) {
        return (A)withAddressType(new String(arg1));
    }

    public A withNewAddressType(StringBuffer arg1) {
        return (A)withAddressType(new String(arg1));
    }

    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 A withNewApiVersion(String arg1) {
        return (A)withApiVersion(new String(arg1));
    }

    public A withNewApiVersion(StringBuilder arg1) {
        return (A)withApiVersion(new String(arg1));
    }

    public A withNewApiVersion(StringBuffer arg1) {
        return (A)withApiVersion(new String(arg1));
    }

    public A addToEndpoints(int index,V1beta1Endpoint item) {
        if (this.endpoints == null) {this.endpoints = new ArrayList();}
        V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);_visitables.get("endpoints").add(index >= 0 ? index : _visitables.get("endpoints").size(), builder);this.endpoints.add(index >= 0 ? index : endpoints.size(), builder); return (A)this;
    }

    public A setToEndpoints(int index,V1beta1Endpoint item) {
        if (this.endpoints == null) {this.endpoints = new ArrayList();}
        V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);
        if (index < 0 || index >= _visitables.get("endpoints").size()) { _visitables.get("endpoints").add(builder); } else { _visitables.get("endpoints").set(index, builder);}
        if (index < 0 || index >= endpoints.size()) { endpoints.add(builder); } else { endpoints.set(index, builder);}
         return (A)this;
    }

    public A addToEndpoints(V1beta1Endpoint... items) {
        if (this.endpoints == null) {this.endpoints = new ArrayList();}
        for (V1beta1Endpoint item : items) {V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);_visitables.get("endpoints").add(builder);this.endpoints.add(builder);} return (A)this;
    }

    public A addAllToEndpoints(Collection items) {
        if (this.endpoints == null) {this.endpoints = new ArrayList();}
        for (V1beta1Endpoint item : items) {V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);_visitables.get("endpoints").add(builder);this.endpoints.add(builder);} return (A)this;
    }

    public A removeFromEndpoints(V1beta1Endpoint... items) {
        for (V1beta1Endpoint item : items) {V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);_visitables.get("endpoints").remove(builder);if (this.endpoints != null) {this.endpoints.remove(builder);}} return (A)this;
    }

    public A removeAllFromEndpoints(Collection items) {
        for (V1beta1Endpoint item : items) {V1beta1EndpointBuilder builder = new V1beta1EndpointBuilder(item);_visitables.get("endpoints").remove(builder);if (this.endpoints != null) {this.endpoints.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromEndpoints(io.kubernetes.client.fluent.Predicate predicate) {
        if (endpoints == null) return (A) this;
        final Iterator each = endpoints.iterator();
        final List visitables = _visitables.get("endpoints");
        while (each.hasNext()) {
          V1beta1EndpointBuilder builder = each.next();
          if (predicate.apply(builder)) {
            visitables.remove(builder);
            each.remove();
          }
        }
        return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildEndpoints instead.
 * @return The buildable object.
 */
@Deprecated public List getEndpoints() {
        return build(endpoints);
    }

    public List buildEndpoints() {
        return build(endpoints);
    }

    public V1beta1Endpoint buildEndpoint(int index) {
        return this.endpoints.get(index).build();
    }

    public V1beta1Endpoint buildFirstEndpoint() {
        return this.endpoints.get(0).build();
    }

    public V1beta1Endpoint buildLastEndpoint() {
        return this.endpoints.get(endpoints.size() - 1).build();
    }

    public V1beta1Endpoint buildMatchingEndpoint(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1EndpointBuilder item: endpoints) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingEndpoint(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1EndpointBuilder item: endpoints) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withEndpoints(List endpoints) {
        if (this.endpoints != null) { _visitables.get("endpoints").removeAll(this.endpoints);}
        if (endpoints != null) {this.endpoints = new ArrayList(); for (V1beta1Endpoint item : endpoints){this.addToEndpoints(item);}} else { this.endpoints = null;} return (A) this;
    }

    public A withEndpoints(V1beta1Endpoint... endpoints) {
        if (this.endpoints != null) {this.endpoints.clear();}
        if (endpoints != null) {for (V1beta1Endpoint item :endpoints){ this.addToEndpoints(item);}} return (A) this;
    }

    public Boolean hasEndpoints() {
        return endpoints != null && !endpoints.isEmpty();
    }

    public V1beta1EndpointSliceFluent.EndpointsNested addNewEndpoint() {
        return new EndpointsNestedImpl();
    }

    public V1beta1EndpointSliceFluent.EndpointsNested addNewEndpointLike(V1beta1Endpoint item) {
        return new EndpointsNestedImpl(-1, item);
    }

    public V1beta1EndpointSliceFluent.EndpointsNested setNewEndpointLike(int index,V1beta1Endpoint item) {
        return new EndpointsNestedImpl(index, item);
    }

    public V1beta1EndpointSliceFluent.EndpointsNested editEndpoint(int index) {
        if (endpoints.size() <= index) throw new RuntimeException("Can't edit endpoints. Index exceeds size.");
        return setNewEndpointLike(index, buildEndpoint(index));
    }

    public V1beta1EndpointSliceFluent.EndpointsNested editFirstEndpoint() {
        if (endpoints.size() == 0) throw new RuntimeException("Can't edit first endpoints. The list is empty.");
        return setNewEndpointLike(0, buildEndpoint(0));
    }

    public V1beta1EndpointSliceFluent.EndpointsNested editLastEndpoint() {
        int index = endpoints.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last endpoints. The list is empty.");
        return setNewEndpointLike(index, buildEndpoint(index));
    }

    public V1beta1EndpointSliceFluent.EndpointsNested editMatchingEndpoint(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i withNewMetadata() {
        return new MetadataNestedImpl();
    }

    public V1beta1EndpointSliceFluent.MetadataNested withNewMetadataLike(V1ObjectMeta item) {
        return new MetadataNestedImpl(item);
    }

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

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

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

    public A addToPorts(int index,V1beta1EndpointPort item) {
        if (this.ports == null) {this.ports = new ArrayList();}
        V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);_visitables.get("ports").add(index >= 0 ? index : _visitables.get("ports").size(), builder);this.ports.add(index >= 0 ? index : ports.size(), builder); return (A)this;
    }

    public A setToPorts(int index,V1beta1EndpointPort item) {
        if (this.ports == null) {this.ports = new ArrayList();}
        V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);
        if (index < 0 || index >= _visitables.get("ports").size()) { _visitables.get("ports").add(builder); } else { _visitables.get("ports").set(index, builder);}
        if (index < 0 || index >= ports.size()) { ports.add(builder); } else { ports.set(index, builder);}
         return (A)this;
    }

    public A addToPorts(V1beta1EndpointPort... items) {
        if (this.ports == null) {this.ports = new ArrayList();}
        for (V1beta1EndpointPort item : items) {V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);_visitables.get("ports").add(builder);this.ports.add(builder);} return (A)this;
    }

    public A addAllToPorts(Collection items) {
        if (this.ports == null) {this.ports = new ArrayList();}
        for (V1beta1EndpointPort item : items) {V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);_visitables.get("ports").add(builder);this.ports.add(builder);} return (A)this;
    }

    public A removeFromPorts(V1beta1EndpointPort... items) {
        for (V1beta1EndpointPort item : items) {V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);_visitables.get("ports").remove(builder);if (this.ports != null) {this.ports.remove(builder);}} return (A)this;
    }

    public A removeAllFromPorts(Collection items) {
        for (V1beta1EndpointPort item : items) {V1beta1EndpointPortBuilder builder = new V1beta1EndpointPortBuilder(item);_visitables.get("ports").remove(builder);if (this.ports != null) {this.ports.remove(builder);}} return (A)this;
    }

    public A removeMatchingFromPorts(io.kubernetes.client.fluent.Predicate predicate) {
        if (ports == null) return (A) this;
        final Iterator each = ports.iterator();
        final List visitables = _visitables.get("ports");
        while (each.hasNext()) {
          V1beta1EndpointPortBuilder builder = each.next();
          if (predicate.apply(builder)) {
            visitables.remove(builder);
            each.remove();
          }
        }
        return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildPorts instead.
 * @return The buildable object.
 */
@Deprecated public List getPorts() {
        return build(ports);
    }

    public List buildPorts() {
        return build(ports);
    }

    public V1beta1EndpointPort buildPort(int index) {
        return this.ports.get(index).build();
    }

    public V1beta1EndpointPort buildFirstPort() {
        return this.ports.get(0).build();
    }

    public V1beta1EndpointPort buildLastPort() {
        return this.ports.get(ports.size() - 1).build();
    }

    public V1beta1EndpointPort buildMatchingPort(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1EndpointPortBuilder item: ports) { if(predicate.apply(item)){ return item.build();} } return null;
    }

    public Boolean hasMatchingPort(io.kubernetes.client.fluent.Predicate predicate) {
        for (V1beta1EndpointPortBuilder item: ports) { if(predicate.apply(item)){ return true;} } return false;
    }

    public A withPorts(List ports) {
        if (this.ports != null) { _visitables.get("ports").removeAll(this.ports);}
        if (ports != null) {this.ports = new ArrayList(); for (V1beta1EndpointPort item : ports){this.addToPorts(item);}} else { this.ports = null;} return (A) this;
    }

    public A withPorts(V1beta1EndpointPort... ports) {
        if (this.ports != null) {this.ports.clear();}
        if (ports != null) {for (V1beta1EndpointPort item :ports){ this.addToPorts(item);}} return (A) this;
    }

    public Boolean hasPorts() {
        return ports != null && !ports.isEmpty();
    }

    public V1beta1EndpointSliceFluent.PortsNested addNewPort() {
        return new PortsNestedImpl();
    }

    public V1beta1EndpointSliceFluent.PortsNested addNewPortLike(V1beta1EndpointPort item) {
        return new PortsNestedImpl(-1, item);
    }

    public V1beta1EndpointSliceFluent.PortsNested setNewPortLike(int index,V1beta1EndpointPort item) {
        return new PortsNestedImpl(index, item);
    }

    public V1beta1EndpointSliceFluent.PortsNested editPort(int index) {
        if (ports.size() <= index) throw new RuntimeException("Can't edit ports. Index exceeds size.");
        return setNewPortLike(index, buildPort(index));
    }

    public V1beta1EndpointSliceFluent.PortsNested editFirstPort() {
        if (ports.size() == 0) throw new RuntimeException("Can't edit first ports. The list is empty.");
        return setNewPortLike(0, buildPort(0));
    }

    public V1beta1EndpointSliceFluent.PortsNested editLastPort() {
        int index = ports.size() - 1;
        if (index < 0) throw new RuntimeException("Can't edit last ports. The list is empty.");
        return setNewPortLike(index, buildPort(index));
    }

    public V1beta1EndpointSliceFluent.PortsNested editMatchingPort(io.kubernetes.client.fluent.Predicate predicate) {
        int index = -1;
        for (int i=0;i extends V1beta1EndpointFluentImpl> implements V1beta1EndpointSliceFluent.EndpointsNested,io.kubernetes.client.fluent.Nested {
        private final V1beta1EndpointBuilder builder;
        private final int index;

        EndpointsNestedImpl(int index,V1beta1Endpoint item) {
            this.index = index;
            this.builder = new V1beta1EndpointBuilder(this, item);
        }

        EndpointsNestedImpl() {
            this.index = -1;
            this.builder = new V1beta1EndpointBuilder(this);
        }

        public N and() {
             return (N) V1beta1EndpointSliceFluentImpl.this.setToEndpoints(index,builder.build());
        }

        public N endEndpoint() {
             return and();
        }
    }


    public class MetadataNestedImpl extends V1ObjectMetaFluentImpl> implements V1beta1EndpointSliceFluent.MetadataNested,io.kubernetes.client.fluent.Nested {
        private final V1ObjectMetaBuilder builder;

        MetadataNestedImpl(V1ObjectMeta item) {
            this.builder = new V1ObjectMetaBuilder(this, item);
        }

        MetadataNestedImpl() {
            this.builder = new V1ObjectMetaBuilder(this);
        }

        public N and() {
             return (N) V1beta1EndpointSliceFluentImpl.this.withMetadata(builder.build());
        }

        public N endMetadata() {
             return and();
        }
    }


    public class PortsNestedImpl extends V1beta1EndpointPortFluentImpl> implements V1beta1EndpointSliceFluent.PortsNested,io.kubernetes.client.fluent.Nested {
        private final V1beta1EndpointPortBuilder builder;
        private final int index;

        PortsNestedImpl(int index,V1beta1EndpointPort item) {
            this.index = index;
            this.builder = new V1beta1EndpointPortBuilder(this, item);
        }

        PortsNestedImpl() {
            this.index = -1;
            this.builder = new V1beta1EndpointPortBuilder(this);
        }

        public N and() {
             return (N) V1beta1EndpointSliceFluentImpl.this.setToPorts(index,builder.build());
        }

        public N endPort() {
             return and();
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy