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

net.openhft.chronicle.testframework.internal.apimetrics.StandardMetric Maven / Gradle / Ivy

There is a newer version: 2.27ea0
Show newest version
package net.openhft.chronicle.testframework.internal.apimetrics;

import net.openhft.chronicle.testframework.apimetrics.Metric;

import java.util.function.Predicate;

import static java.util.Objects.requireNonNull;

public class StandardMetric implements Metric {

    private final Class nodeType;
    private final Predicate filter;
    private final String name;
    private final double weight;
    //private final double factor;

    public StandardMetric(final Class nodeType,
                          final Predicate filter,
                          final String name,
                          final double weight) {
        this.nodeType = requireNonNull(nodeType);
        this.filter = requireNonNull(filter);
        this.name = requireNonNull(name);
        this.weight = weight;
    }

    @Override
    public Class nodeType() {
        return nodeType;
    }

    @Override
    public boolean isApplicable(T node) {
        return filter.test(node);
    }

    @Override
    public double weight() {
        return weight;
    }

    @Override
    public String toString() {
        return name;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy