本文整理了Java中com.netflix.spectator.api.Utils.filter()
方法的一些代码示例,展示了Utils.filter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.filter()
方法的具体详情如下:
包路径:com.netflix.spectator.api.Utils
类名称:Utils
方法名:filter
[英]Returns a new iterable restricted to measurements that match the predicate.
[中]返回一个新的iterable,该值仅限于与谓词匹配的度量值。
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Returns the first measurement that matches the predicate.
*
* @param ms
* A set of measurements.
* @param p
* Predicate to use for selecting values.
* @return
* Measurement or null if no matches are found.
*/
public static Measurement first(Iterable<Measurement> ms, Predicate<Measurement> p) {
Iterator<Measurement> it = filter(ms, p).iterator();
return it.hasNext() ? it.next() : null;
}
代码示例来源:origin: Netflix/spectator
/**
* Returns the first measurement that matches the predicate.
*
* @param ms
* A set of measurements.
* @param p
* Predicate to use for selecting values.
* @return
* Measurement or null if no matches are found.
*/
public static Measurement first(Iterable<Measurement> ms, Predicate<Measurement> p) {
Iterator<Measurement> it = filter(ms, p).iterator();
return it.hasNext() ? it.next() : null;
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a new iterable restricted to measurements that match the predicate.
*
* @param ms
* A set of measurements.
* @param k
* Key to search for.
* @param v
* Value that should be associated with k on the ids.
* @return
* Measurements matching the predicate.
*/
public static Iterable<Measurement> filter(
final Iterable<Measurement> ms, final String k, final String v) {
return filter(ms, value -> v.equals(getTagValue(value.id(), k)));
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Returns a new iterable restricted to measurements that match the predicate.
*
* @param ms
* A set of measurements.
* @param k
* Key to search for.
* @param v
* Value that should be associated with k on the ids.
* @return
* Measurements matching the predicate.
*/
public static Iterable<Measurement> filter(
final Iterable<Measurement> ms, final String k, final String v) {
return filter(ms, value -> v.equals(getTagValue(value.id(), k)));
}
代码示例来源:origin: Netflix/spectator
/**
* Returns a new iterable restricted to measurements that match the predicate.
*
* @param ms
* A set of measurements.
* @param t
* The key and value to search for.
* @return
* Measurements matching the predicate.
*/
public static Iterable<Measurement> filter(Iterable<Measurement> ms, Tag t) {
return filter(ms, t.key(), t.value());
}
代码示例来源:origin: com.netflix.spectator/spectator-api
/**
* Returns a new iterable restricted to measurements that match the predicate.
*
* @param ms
* A set of measurements.
* @param t
* The key and value to search for.
* @return
* Measurements matching the predicate.
*/
public static Iterable<Measurement> filter(Iterable<Measurement> ms, Tag t) {
return filter(ms, t.key(), t.value());
}
代码示例来源:origin: Netflix/spectator
@Test
public void filterPredicateEmpty() {
List<Measurement> ms = newList(10);
List<Measurement> out = Utils.toList(Utils.filter(ms, v -> false));
Assertions.assertEquals(0, out.size());
}
}
代码示例来源:origin: Netflix/spectator
@Test
public void filterTag() {
List<Measurement> ms = newList(10);
Tag t = new BasicTag("i", "7");
List<Measurement> out = Utils.toList(Utils.filter(ms, t));
Assertions.assertEquals(1, out.size());
Assertions.assertEquals(out.get(0).id().tags(), ArrayTagSet.create(t));
}
代码示例来源:origin: Netflix/spectator
@Test
public void filterKV() {
List<Measurement> ms = newList(10);
Tag t = new BasicTag("i", "7");
List<Measurement> out = Utils.toList(Utils.filter(ms, "i", "7"));
Assertions.assertEquals(1, out.size());
Assertions.assertEquals(out.get(0).id().tags(), ArrayTagSet.create(t));
}
代码示例来源:origin: Netflix/spectator
@Test
public void filterPredicate() {
List<Measurement> ms = newList(10);
Tag t = new BasicTag("i", "7");
List<Measurement> out = Utils.toList(Utils.filter(ms, v -> v.value() == 7.0));
Assertions.assertEquals(1, out.size());
Assertions.assertEquals(out.get(0).id().tags(), ArrayTagSet.create(t));
}
内容来源于网络,如有侵权,请联系作者删除!