下面列出了java.util.SortedSet#forEach ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void encodeOwsDCP(OwsDCP dcp, DCP xdcp) {
if (dcp.isHTTP()) {
HTTP xhttp = xdcp.addNewHTTP();
OwsHttp http = dcp.asHTTP();
SortedSet<OwsRequestMethod> requestMethods = http.getRequestMethods();
requestMethods.forEach(method -> {
RequestMethodType xmethod;
switch (method.getHttpMethod()) {
case HTTPMethods.GET:
xmethod = xhttp.addNewGet();
break;
case HTTPMethods.POST:
xmethod = xhttp.addNewPost();
break;
default:
return;
}
encodeOnlineResource(method, xmethod);
method.getConstraints().forEach(x -> encodeOwsDomain(x, xmethod.addNewConstraint()));
});
}
}
public void forEach(QueryOptions filter, Consumer<? super Node> consumer) {
for (Map.Entry<ImmutableContextSet, SortedSet<Node>> e : this.map.entrySet()) {
if (!filter.satisfies(e.getKey(), defaultSatisfyMode())) {
continue;
}
if (normalNodesExcludeTest(filter, e.getKey())) {
if (inheritanceNodesIncludeTest(filter, e.getKey())) {
// only copy inheritance nodes.
SortedSet<InheritanceNode> inheritanceNodes = this.inheritanceMap.get(e.getKey());
if (inheritanceNodes != null) {
inheritanceNodes.forEach(consumer);
}
}
} else {
e.getValue().forEach(consumer);
}
}
}
@Override
protected void doExecute() {
TelemetryConfigService service = get(TelemetryConfigService.class);
TelemetryConfig config = service.getConfig(configName);
if (config == null) {
print(NO_ELEMENT);
return;
}
SortedSet<String> keys = new TreeSet<>(config.properties().keySet());
keys.forEach(k -> {
print(FORMAT, k, config.properties().get(k));
});
}
@Override
public List<ExtensionRepoExtensionMetadata> getExtensionRepoExtensions(final URI baseUri, final String bucketName, final String groupId,
final String artifactId, final String version) {
final Bucket bucket = registryService.getBucketByName(bucketName);
authorizeBucketAccess(RequestAction.READ, bucket.getIdentifier());
final BundleVersion bundleVersion = extensionService.getBundleVersion(bucket.getIdentifier(), groupId, artifactId, version);
final SortedSet<ExtensionMetadata> extensions = extensionService.getExtensionMetadata(bundleVersion);
final List<ExtensionRepoExtensionMetadata> extensionRepoExtensions = new ArrayList<>(extensions.size());
extensions.forEach(e -> extensionRepoExtensions.add(new ExtensionRepoExtensionMetadata(e)));
linkService.populateFullLinks(extensionRepoExtensions, baseUri);
return extensionRepoExtensions;
}
@PreDestroy
public void destroy() {
log.info("Remove Cache Manager metrics");
SortedSet<String> names = metricRegistry.getNames();
names.forEach(metricRegistry::remove);
log.info("Closing Cache Manager");
cacheManager.shutdown();
}
/**
*
* @param sourceListing
* @return
*/
public static Vector<String> vectorSortedUniqueMembers(String[][] sourceListing){
SortedSet<String> treeSet = new TreeSet<>();
for (String[] sourceListing1 : sourceListing) {
treeSet.addAll(Arrays.asList(sourceListing1));
}
Vector<String> retval = new Vector<>();
treeSet.forEach((s) -> {
retval.add( s );
});
return retval;
}
@Path("/sortedSetQueryParam")
@GET
public String testSortedSetQueryParam(@QueryParam("id") SortedSet<Integer> ids) {
StringBuilder response = new StringBuilder();
ids.forEach(id -> response.append(id).append(","));
if (response.length() > 0) {
response.setLength(response.length() - 1);
}
return response.toString();
}
private void processOutgoingInterfaceEdges(
String outgoingInterface, Ip nextHopIp, SortedSet<NodeInterfacePair> neighborIfaces) {
checkArgument(!neighborIfaces.isEmpty(), "No neighbor interfaces.");
checkState(
_steps.get(_steps.size() - 1) instanceof ExitOutputIfaceStep,
"ExitOutputIfaceStep needs to be added before calling this function");
Ip arpIp =
Route.UNSET_ROUTE_NEXT_HOP_IP.equals(nextHopIp) ? _currentFlow.getDstIp() : nextHopIp;
SortedSet<NodeInterfacePair> interfacesThatReplyToArp =
neighborIfaces.stream()
.filter(
iface ->
_tracerouteContext.repliesToArp(
iface.getHostname(), iface.getInterface(), arpIp))
.collect(ImmutableSortedSet.toImmutableSortedSet(Ordering.natural()));
if (interfacesThatReplyToArp.isEmpty()) {
FlowDisposition disposition =
_tracerouteContext.computeDisposition(
_currentNode.getName(), outgoingInterface, _currentFlow.getDstIp());
buildArpFailureTrace(outgoingInterface, arpIp, disposition);
return;
}
Hop hop = new Hop(_currentNode, _steps);
_hops.add(hop);
NodeInterfacePair exitIface = NodeInterfacePair.of(_currentNode.getName(), outgoingInterface);
interfacesThatReplyToArp.forEach(
enterIface -> forkTracerFollowEdge(exitIface, enterIface).processHop());
}
/**
* Builds a port map string composing of 1 and 0s.
* BMv2 API reads a port map from most significant to least significant char.
* Index of 1s indicates port numbers.
* For example, if port numbers are 4,3 and 1, the generated port map string looks like 11010.
*
* @param outPorts set of output port numbers
* @return port map string
*/
private static String buildPortMap(Set<PortNumber> outPorts) {
//Sorts port numbers in descending order
SortedSet<PortNumber> outPortsSorted = new TreeSet<>((o1, o2) -> (int) (o2.toLong() - o1.toLong()));
outPortsSorted.addAll(outPorts);
PortNumber biggestPort = outPortsSorted.iterator().next();
int portMapSize = (int) biggestPort.toLong() + 1;
//init and fill port map with zero characters
char[] portMap = new char[portMapSize];
Arrays.fill(portMap, '0');
//fill in the ports with 1
outPortsSorted.forEach(portNumber -> portMap[portMapSize - (int) portNumber.toLong() - 1] = '1');
return String.valueOf(portMap);
}
@EventListener
public void onRemoveSelected(RemoveSelectedEvent event) {
SortedSet<Integer> indices = new TreeSet<>(Collections.reverseOrder());
indices.addAll(getSelectionModel().getSelectedIndices());
LOG.trace("Removing {} items", indices.size());
indices.forEach(i -> getItems().remove(i.intValue()).invalidate());
requestFocus();
}
@Test
public void happyCase() throws Exception {
// given
LeaseItem leaseItem = lease.findItem(LeaseItemType.SERVICE_CHARGE, VT.ld(2010, 7, 15), VT.bi(1));
assertThat(leaseItem).isNotNull();
assertThat(leaseItem.getInvoicingFrequency()).isEqualTo(InvoicingFrequency.QUARTERLY_IN_ADVANCE);
final SortedSet<LeaseTerm> terms = leaseItem.getTerms();
terms.forEach(leaseTerm -> assertThat(leaseTerm.getInvoiceItems()).isEmpty());
// when
wrap(leaseItem).changeInvoicingFrequency(InvoicingFrequency.MONTHLY_IN_ADVANCE);
// then
assertThat(leaseItem.getInvoicingFrequency()).isEqualTo(InvoicingFrequency.MONTHLY_IN_ADVANCE);
}
private static SortedSet<Long> windowIndicesToWindows(SortedSet<Long> original, long windowMs) {
SortedSet<Long> result = new TreeSet<>(Collections.reverseOrder());
original.forEach(idx -> result.add(idx * windowMs));
return result;
}
private List<Long> toWindows(SortedSet<Long> windowIndices) {
List<Long> windows = new ArrayList<>(windowIndices.size());
windowIndices.forEach(i -> windows.add(i * _windowMs));
return windows;
}