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

com.ringcentral.platform.metrics.infoProviders.PredicativeMetricNamedInfoProvider Maven / Gradle / Ivy

package com.ringcentral.platform.metrics.infoProviders;

import com.ringcentral.platform.metrics.predicates.MetricNamedPredicate;
import com.ringcentral.platform.metrics.predicates.MetricNamedPredicateBuilder;

import java.util.function.Predicate;

public interface PredicativeMetricNamedInfoProvider extends MetricNamedInfoProvider {
    default PredicativeMetricNamedInfoProvider addInfo(MetricNamedPredicateBuilder predicateBuilder, I info) {
        return addInfo(predicateBuilder.build(), info);
    }

    default PredicativeMetricNamedInfoProvider addInfo(MetricNamedPredicate predicate, I info) {
        return addInfo(null, predicate, info);
    }

    default PredicativeMetricNamedInfoProvider addInfo(String key, MetricNamedPredicateBuilder predicateBuilder, I info) {
        return addInfo(key, predicateBuilder.build(), info);
    }

    /**
     * Adds the specified info by the specified key.
     * You can further remove the info using the {@link #removeInfo} method after it's no longer needed.
     *
     * @param key key with which the info is to be associated.
     *            May be null, in which case there will be no association, and you won't be able to remove the info.
     */
    PredicativeMetricNamedInfoProvider addInfo(String key, MetricNamedPredicate predicate, I info);

    /**
     * Removes the info previously added by the specified key.
     */
    PredicativeMetricNamedInfoProvider removeInfo(String key);

    /**
     * Removes all the information previously added by the specified keys that satisfy the given predicate.
     */
    PredicativeMetricNamedInfoProvider removeInfos(Predicate keyPredicate);
}