本文整理了Java中java.util.Stack.stream()
方法的一些代码示例,展示了Stack.stream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.stream()
方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:stream
暂无
代码示例来源:origin: pmd/pmd
@PersistentProperty
public String getRecentFiles() {
return recentFiles.stream().map(File::getAbsolutePath).collect(Collectors.joining(File.pathSeparator));
}
代码示例来源:origin: benas/random-beans
private List<String> getStackedFieldNames() {
return stack.stream().map(i -> i.getField().getName()).collect(toList());
}
代码示例来源:origin: cincheo/jsweet
private static <T> void dumpCycles(List<Node<T>> nodes, Stack<Node<T>> path, Function<T, String> toString) {
path.peek().outEdges.stream().map(e -> e.to).forEach(node -> {
if (nodes.contains(node)) {
if (path.contains(node)) {
System.out.println(
"cycle: " + path.stream().map(n -> toString.apply(n.element)).collect(Collectors.toList()));
} else {
path.push(node);
dumpCycles(nodes, path, toString);
path.pop();
}
}
});
;
}
代码示例来源:origin: com.typesafe.play/play
/**
* Create a canonical path that does not contain parent directories, current directories, or superfluous directory
* separators.
*/
public static String canonical(String url) {
String[] urlPath = toSegments(url);
Stack<String> canonical = new Stack<>();
for (String comp : urlPath) {
if (comp.isEmpty() || comp.equals(CURRENT_DIR))
continue;
if (!comp.equals(PARENT_DIR) || (!canonical.empty() && canonical.peek().equals(PARENT_DIR)))
canonical.push(comp);
else
canonical.pop();
}
String prefixSep = url.startsWith(SEPARATOR) ? SEPARATOR : "";
String trailingSep = url.endsWith(SEPARATOR) ? SEPARATOR : "";
return prefixSep + canonical.stream().collect(Collectors.joining(SEPARATOR)) + trailingSep;
}
代码示例来源:origin: com.typesafe.play/play_2.11
/**
* Create a canonical path that does not contain parent directories, current directories, or superfluous directory
* separators.
*/
public static String canonical(String url) {
String[] urlPath = toSegments(url);
Stack<String> canonical = new Stack<>();
for (String comp : urlPath) {
if (comp.isEmpty() || comp.equals(CURRENT_DIR))
continue;
if (!comp.equals(PARENT_DIR) || (!canonical.empty() && canonical.peek().equals(PARENT_DIR)))
canonical.push(comp);
else
canonical.pop();
}
String prefixSep = url.startsWith(SEPARATOR) ? SEPARATOR : "";
String trailingSep = url.endsWith(SEPARATOR) ? SEPARATOR : "";
return prefixSep + canonical.stream().collect(Collectors.joining(SEPARATOR)) + trailingSep;
}
代码示例来源:origin: com.typesafe.play/play_2.12
/**
* Create a canonical path that does not contain parent directories, current directories, or superfluous directory
* separators.
*/
public static String canonical(String url) {
String[] urlPath = toSegments(url);
Stack<String> canonical = new Stack<>();
for (String comp : urlPath) {
if (comp.isEmpty() || comp.equals(CURRENT_DIR))
continue;
if (!comp.equals(PARENT_DIR) || (!canonical.empty() && canonical.peek().equals(PARENT_DIR)))
canonical.push(comp);
else
canonical.pop();
}
String prefixSep = url.startsWith(SEPARATOR) ? SEPARATOR : "";
String trailingSep = url.endsWith(SEPARATOR) ? SEPARATOR : "";
return prefixSep + canonical.stream().collect(Collectors.joining(SEPARATOR)) + trailingSep;
}
代码示例来源:origin: artex-development/Lukkit
public static Optional<Stream<Exception>> getErrors() {
// Filter out all the nulls from the stream, only returning the Error object and not nulls (Stack#setSize sets the size and fills with nulls if nothing exists)
return (errors.stream().filter(Objects::nonNull).count() == 0) ? Optional.empty() : Optional.of(errors.stream().filter(Objects::nonNull));
}
代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-core-common
public List<Node<View, Edge>> asList() {
return stack.stream()
.collect(Collectors.toList());
}
代码示例来源:origin: com.google.api/api-compiler
public String getFullyQualifiedName() {
return fullyQualifiedNameComponents
.stream()
.filter(s -> !Strings.isNullOrEmpty(s.trim()))
.collect(Collectors.joining("."));
}
代码示例来源:origin: aws/amazon-kinesis-video-streams-parser-library
private List<EBMLElementMetaData> currentElementPath() {
return masterElements.stream().map(EBMLParserInternalElement::getMetadata).collect(Collectors.toList());
}
代码示例来源:origin: googleapis/api-compiler
public String getFullyQualifiedName() {
return fullyQualifiedNameComponents
.stream()
.filter(s -> !Strings.isNullOrEmpty(s.trim()))
.collect(Collectors.joining("."));
}
代码示例来源:origin: org.ballerinalang/language-server-core
/**
* Get the string values list of forced consumed tokens, from the LSContext.
*
* @param ctx Language Server context
* @return {@link List} Token string list
*/
public static List<String> getPoppedTokenStrings(LSContext ctx) {
return ctx.get(CompletionKeys.FORCE_CONSUMED_TOKENS_KEY).stream()
.map(Token::getText)
.collect(Collectors.toList());
}
代码示例来源:origin: synchrony/smsn
private void cleanup(final long timestamp) {
cleanupBuffer.addAll(latestHandoffs.stream().filter(h -> isOld(h, timestamp)).collect(Collectors.toList()));
if (cleanupBuffer.size() > 0) {
cleanupBuffer.forEach(latestHandoffs::remove);
cleanupBuffer.clear();
}
}
代码示例来源:origin: synchrony/smsn
private void cleanup(final long timestamp) {
cleanupBuffer.addAll(latestHandshakeSequences.stream().filter(h -> isOld(h, timestamp)).collect(Collectors.toList()));
if (cleanupBuffer.size() > 0) {
for (HandshakeSequence h : cleanupBuffer) {
latestHandshakeSequences.remove(h);
handshakesByActor.remove(h.actor);
}
cleanupBuffer.clear();
}
}
代码示例来源:origin: io.github.benas/random-beans
private List<String> getStackedFieldNames() {
return stack.stream().map(i -> i.getField().getName()).collect(toList());
}
代码示例来源:origin: org.ballerinalang/language-server-core
/**
* Get the variable type.
* @param ctx Document Service context (Completion context)
* @return {@link String} type of the variable
*/
String getVariableType(LSServiceOperationContext ctx) {
List<String> poppedTokens = ctx.get(CompletionKeys.FORCE_CONSUMED_TOKENS_KEY)
.stream()
.map(Token::getText)
.collect(Collectors.toList());
return poppedTokens.get(0);
}
}
代码示例来源:origin: org.ballerinalang/language-server-core
/**
* Check whether the token stream corresponds to a action invocation or a function invocation.
*
* @param context Completion operation context
* @return {@link Boolean} Whether invocation or Field Access
*/
@Override
protected boolean isInvocationOrInteractionOrFieldAccess(LSServiceOperationContext context) {
List<String> poppedTokens = context.get(CompletionKeys.FORCE_CONSUMED_TOKENS_KEY)
.stream()
.map(Token::getText)
.collect(Collectors.toList());
String topMostPoppedToken = CommonUtil.getLastItem(poppedTokens);
return (poppedTokens.size() > 2)
&& (UtilSymbolKeys.PKG_DELIMITER_KEYWORD.equals(topMostPoppedToken)
|| UtilSymbolKeys.DOT_SYMBOL_KEY.equals(topMostPoppedToken));
}
}
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public List<CompletionItem> resolveItems(LSServiceOperationContext ctx) {
ArrayList<CompletionItem> completionItems = new ArrayList<>();
List<BallerinaPackage> packagesList = new ArrayList<>();
Stream.of(LSPackageLoader.getSdkPackages(), LSPackageLoader.getHomeRepoPackages())
.forEach(packagesList::addAll);
List<String> poppedTokens = ctx.get(CompletionKeys.FORCE_CONSUMED_TOKENS_KEY)
.stream()
.map(Token::getText)
.collect(Collectors.toList());
if (poppedTokens.contains(UtilSymbolKeys.SLASH_KEYWORD_KEY)) {
String orgName = poppedTokens.get(poppedTokens.indexOf(UtilSymbolKeys.SLASH_KEYWORD_KEY) - 1);
completionItems.addAll(this.getPackageNameCompletions(orgName, packagesList));
} else if (poppedTokens.contains(UtilSymbolKeys.IMPORT_KEYWORD_KEY)) {
completionItems.addAll(this.getOrgNameCompletionItems(packagesList));
}
return completionItems;
}
代码示例来源:origin: spotify/flo
private static void popSubTree(List<TaskInfo> inputs, BiConsumer<TaskId, String> consumer, Stack<Boolean> indents) {
for (int i = 0; i < inputs.size(); i++) {
final TaskInfo taskInfo = inputs.get(i);
final String indent = indents.stream()
.map(b -> b ? " " : "│ ")
.collect(joining());
final String branch = (i < inputs.size() - 1) ? "├" : "└";
final String prefix = indent + branch + "▸ ";
final String refArrow = taskInfo.isReference()
? " ⤴"
: "";
consumer.accept(taskInfo.id(), prefix + taskInfo.id() + refArrow);
indents.push(i == inputs.size() - 1);
popSubTree(taskInfo.inputs(), consumer, indents);
indents.pop();
}
}
}
代码示例来源:origin: org.ballerinalang/language-server-core
@Override
public List<CompletionItem> resolveItems(LSServiceOperationContext context) {
List<String> consumedTokens = context.get(CompletionKeys.FORCE_CONSUMED_TOKENS_KEY).stream()
.map(Token::getText)
.collect(Collectors.toList());
if (consumedTokens.get(0).equals(UtilSymbolKeys.FUNCTION_KEYWORD_KEY)) {
return CompletionItemResolver.get(BallerinaParser.DefinitionContext.class)
.resolveItems(context);
}
return CompletionItemResolver
.get(BallerinaParser.VariableDefinitionStatementContext.class).resolveItems(context);
}
}
内容来源于网络,如有侵权,请联系作者删除!