本文整理汇总了Java中com.codepoetics.protonpack.StreamUtils.zip方法的典型用法代码示例。如果您正苦于以下问题:Java StreamUtils.zip方法的具体用法?Java StreamUtils.zip怎么用?Java StreamUtils.zip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.codepoetics.protonpack.StreamUtils
的用法示例。
在下文中一共展示了StreamUtils.zip方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.codepoetics.protonpack.StreamUtils; //导入方法依赖的package包/类
/**
* This service is used to read one or more attributes of one or more nodes.
*
* @param maxAge the requested max age of the value, in milliseconds. If maxAge is set to 0, the Server
* shall attempt to read a new value from the data source. If maxAge is set to the max
* Int32 value or greater, the Server shall attempt to get a cached value. Negative values
* are invalid for maxAge.
* @param timestampsToReturn the requested {@link TimestampsToReturn}.
* @param nodeIds the {@link NodeId}s identifying the nodes to read.
* @param attributeIds the attribute ids to read, the size and order matching the provided {@link NodeId}s.
* @return a {@link CompletableFuture} containing a list of {@link DataValue}s, the size and order matching the
* provided {@link NodeId}s.
*/
default CompletableFuture<List<DataValue>> read(double maxAge,
TimestampsToReturn timestampsToReturn,
List<NodeId> nodeIds,
List<UInteger> attributeIds) {
if (nodeIds.size() != attributeIds.size()) {
CompletableFuture<List<DataValue>> failed = new CompletableFuture<>();
failed.completeExceptionally(new IllegalArgumentException("nodeIds.size() != attributeIds.size()"));
return failed;
} else {
Stream<ReadValueId> stream = StreamUtils.zip(
nodeIds.stream(), attributeIds.stream(),
(nId, aId) -> new ReadValueId(nId, aId, null, QualifiedName.NULL_VALUE));
return read(maxAge, timestampsToReturn, stream.collect(Collectors.toList()))
.thenApply(r -> l(r.getResults()));
}
}
示例2: writeValues
import com.codepoetics.protonpack.StreamUtils; //导入方法依赖的package包/类
/**
* This service is used to write to the value attribute of one or more nodes.
*
* @param nodeIds the {@link NodeId}s identifying the nodes to write to.
* @param values the {@link DataValue}s to write.
* @return a {@link CompletableFuture} containing a list of results for the writes.
*/
default CompletableFuture<List<StatusCode>> writeValues(List<NodeId> nodeIds, List<DataValue> values) {
if (nodeIds.size() != values.size()) {
CompletableFuture<List<StatusCode>> failed = new CompletableFuture<>();
failed.completeExceptionally(new IllegalArgumentException("nodeIds.size() != values.size()"));
return failed;
} else {
Stream<WriteValue> stream = StreamUtils.zip(
nodeIds.stream(), values.stream(),
(nodeId, value) -> new WriteValue(nodeId, uint(13), null, value));
return write(stream.collect(Collectors.toList()))
.thenApply(response -> l(response.getResults()));
}
}