List of usage examples for java.util.stream Stream max
Optional<T> max(Comparator<? super T> comparator);
From source file:com.liferay.blade.cli.command.CreateCommand.java
private void _printTemplates() throws Exception { BladeCLI bladeCLI = getBladeCLI();/*w w w.j a v a 2s. c o m*/ Map<String, String> templates = BladeUtil.getTemplates(bladeCLI); List<String> templateNames = new ArrayList<>(BladeUtil.getTemplateNames(getBladeCLI())); Collections.sort(templateNames); Comparator<String> compareLength = Comparator.comparingInt(String::length); Stream<String> stream = templateNames.stream(); String longestString = stream.max(compareLength).get(); int padLength = longestString.length() + 2; for (String name : templateNames) { PrintStream out = bladeCLI.out(); out.print(StringUtils.rightPad(name, padLength)); bladeCLI.out(templates.get(name)); } }