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

annotations.me.snowdrop.istio.adapter.prometheus.PrometheusFluentImpl Maven / Gradle / Ivy

package me.snowdrop.istio.adapter.prometheus;

import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.fabric8.kubernetes.api.builder.Nested;
import java.util.ArrayList;
import io.fabric8.kubernetes.api.builder.Predicate;
import java.lang.Deprecated;
import javax.validation.Valid;
import io.fabric8.kubernetes.api.builder.BaseFluent;
import java.util.Collection;
import java.lang.Object;
import java.util.List;
import java.lang.Boolean;

public class PrometheusFluentImpl> extends io.fabric8.kubernetes.api.builder.BaseFluent implements PrometheusFluent{

    private List metrics;

    public PrometheusFluentImpl(){
    }
    public PrometheusFluentImpl(Prometheus instance){
            this.withMetrics(instance.getMetrics()); 
    }

    public A addToMetrics(int index,me.snowdrop.istio.adapter.prometheus.MetricInfo item){
            if (this.metrics == null) {this.metrics = new ArrayList();}
            me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);_visitables.add(index >= 0 ? index : _visitables.size(), builder);this.metrics.add(index >= 0 ? index : metrics.size(), builder); return (A)this;
    }

    public A setToMetrics(int index,me.snowdrop.istio.adapter.prometheus.MetricInfo item){
            if (this.metrics == null) {this.metrics = new ArrayList();}
            me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);
            if (index < 0 || index >= _visitables.size()) { _visitables.add(builder); } else { _visitables.set(index, builder);}
            if (index < 0 || index >= metrics.size()) { metrics.add(builder); } else { metrics.set(index, builder);}
             return (A)this;
    }

    public A addToMetrics(me.snowdrop.istio.adapter.prometheus.MetricInfo... items){
            if (this.metrics == null) {this.metrics = new ArrayList();}
            for (me.snowdrop.istio.adapter.prometheus.MetricInfo item : items) {me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);_visitables.add(builder);this.metrics.add(builder);} return (A)this;
    }

    public A addAllToMetrics(Collection items){
            if (this.metrics == null) {this.metrics = new ArrayList();}
            for (me.snowdrop.istio.adapter.prometheus.MetricInfo item : items) {me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);_visitables.add(builder);this.metrics.add(builder);} return (A)this;
    }

    public A removeFromMetrics(me.snowdrop.istio.adapter.prometheus.MetricInfo... items){
            for (me.snowdrop.istio.adapter.prometheus.MetricInfo item : items) {me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);_visitables.remove(builder);if (this.metrics != null) {this.metrics.remove(builder);}} return (A)this;
    }

    public A removeAllFromMetrics(Collection items){
            for (me.snowdrop.istio.adapter.prometheus.MetricInfo item : items) {me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(item);_visitables.remove(builder);if (this.metrics != null) {this.metrics.remove(builder);}} return (A)this;
    }

    
/**
 * This method has been deprecated, please use method buildMetrics instead.
 */
@Deprecated public List getMetrics(){
            return build(metrics);
    }

    public List buildMetrics(){
            return build(metrics);
    }

    public me.snowdrop.istio.adapter.prometheus.MetricInfo buildMetric(int index){
            return this.metrics.get(index).build();
    }

    public me.snowdrop.istio.adapter.prometheus.MetricInfo buildFirstMetric(){
            return this.metrics.get(0).build();
    }

    public me.snowdrop.istio.adapter.prometheus.MetricInfo buildLastMetric(){
            return this.metrics.get(metrics.size() - 1).build();
    }

    public me.snowdrop.istio.adapter.prometheus.MetricInfo buildMatchingMetric(io.fabric8.kubernetes.api.builder.Predicate predicate){
            for (me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder item: metrics) { if(predicate.apply(item)){return item.build();} } return null;
    }

    public A withMetrics(List metrics){
            if (this.metrics != null) { _visitables.removeAll(this.metrics);}
            if (metrics != null) {this.metrics = new ArrayList(); for (me.snowdrop.istio.adapter.prometheus.MetricInfo item : metrics){this.addToMetrics(item);}} else { this.metrics = null;} return (A) this;
    }

    public A withMetrics(me.snowdrop.istio.adapter.prometheus.MetricInfo... metrics){
            this.metrics.clear(); if (metrics != null) {for (me.snowdrop.istio.adapter.prometheus.MetricInfo item :metrics){ this.addToMetrics(item);}} return (A) this;
    }

    public Boolean hasMetrics(){
            return metrics != null && !metrics.isEmpty();
    }

    public PrometheusFluent.MetricsNested addNewMetric(){
            return new MetricsNestedImpl();
    }

    public PrometheusFluent.MetricsNested addNewMetricLike(me.snowdrop.istio.adapter.prometheus.MetricInfo item){
            return new MetricsNestedImpl(-1, item);
    }

    public PrometheusFluent.MetricsNested setNewMetricLike(int index,me.snowdrop.istio.adapter.prometheus.MetricInfo item){
            return new MetricsNestedImpl(index, item);
    }

    public PrometheusFluent.MetricsNested editMetric(int index){
            if (metrics.size() <= index) throw new RuntimeException("Can't edit metrics. Index exceeds size.");
            return setNewMetricLike(index, buildMetric(index));
    }

    public PrometheusFluent.MetricsNested editFirstMetric(){
            if (metrics.size() == 0) throw new RuntimeException("Can't edit first metrics. The list is empty.");
            return setNewMetricLike(0, buildMetric(0));
    }

    public PrometheusFluent.MetricsNested editLastMetric(){
            int index = metrics.size() - 1;
            if (index < 0) throw new RuntimeException("Can't edit last metrics. The list is empty.");
            return setNewMetricLike(index, buildMetric(index));
    }

    public PrometheusFluent.MetricsNested editMatchingMetric(io.fabric8.kubernetes.api.builder.Predicate predicate){
            int index = -1;
            for (int i=0;i extends me.snowdrop.istio.adapter.prometheus.MetricInfoFluentImpl> implements PrometheusFluent.MetricsNested,io.fabric8.kubernetes.api.builder.Nested{

            private final me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder builder;
        private final int index;
    
            MetricsNestedImpl(int index,me.snowdrop.istio.adapter.prometheus.MetricInfo item){
                    this.index = index;
                    this.builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(this, item);
            }
            MetricsNestedImpl(){
                    this.index = -1;
                    this.builder = new me.snowdrop.istio.adapter.prometheus.MetricInfoBuilder(this);
            }
    
    public N and(){
            return (N) PrometheusFluentImpl.this.setToMetrics(index, builder.build());
    }
    public N endMetric(){
            return and();
    }

}


}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy