本文整理了Java中scala.collection.Seq.filter()
方法的一些代码示例,展示了Seq.filter()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Seq.filter()
方法的具体详情如下:
包路径:scala.collection.Seq
类名称:Seq
方法名:filter
暂无
代码示例来源:origin: com.lightbend.akka.grpc/akka-grpc-play-testkit
/**
* Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints.
*
* If no HTTP/2 endpoint exists this throws an IllegalArgumentException.
*/
public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) {
final scala.collection.Traversable<ServerEndpoint> possibleEndpoints =
serverEndpoints.endpoints().filter(func(e->e.expectedHttpVersions().contains("2")));
if (possibleEndpoints.size() != 1) {
throw new IllegalArgumentException(String.format(
"gRPC client can't automatically find HTTP/2 connection: " +
"%s valid endpoints available: %s",
possibleEndpoints.size(),
serverEndpoints
));
}
return possibleEndpoints.head();
}
代码示例来源:origin: com.lightbend.play/play-grpc-testkit
/**
* Unsafely gets the HTTP/2 endpoint from the given ServerEndpoints.
*
* If no HTTP/2 endpoint exists this throws an IllegalArgumentException.
*/
public static ServerEndpoint getHttp2Endpoint(final ServerEndpoints serverEndpoints) {
final scala.collection.Traversable<ServerEndpoint> possibleEndpoints =
serverEndpoints.endpoints().filter(func(e -> e.expectedHttpVersions().contains("2")));
if (possibleEndpoints.size() == 0) {
throw new IllegalArgumentException(String.format(
"gRPC client can't automatically find HTTP/2 connection: " +
"no valid endpoints available. %s",
serverEndpoints
));
} else if (possibleEndpoints.size() == 1) {
return possibleEndpoints.head();
} else {
// TODO: the decision on which HTTP/2 endpoint to use should be based on config (e.g. maybe the user set
// `akka.grpc.client."".use-tls` to false for gRPC so this should return the non-TLS HTTP/2 endpoint on the list.
return possibleEndpoints.filter(endpoint -> endpoint.ssl().isDefined()).head();
}
}
内容来源于网络,如有侵权,请联系作者删除!