List of usage examples for java.util Collections reverse
@SuppressWarnings({ "rawtypes", "unchecked" }) public static void reverse(List<?> list)
This method runs in linear time.
From source file:com.mitre.storefront.breadcrumb.impl.ProductBreadcrumbBuilder.java
public List<Breadcrumb> getBreadcrumbs(final ProductData baseProductData) throws IllegalArgumentException { final List<Breadcrumb> breadcrumbs = new ArrayList<Breadcrumb>(); final Breadcrumb last = getProductBreadcrumb(baseProductData); last.setLinkClass(LAST_LINK_CLASS);//from w w w .j a v a 2s . c om breadcrumbs.add(last); addCategoryBreadCrumbs(breadcrumbs, baseProductData.getCode()); Collections.reverse(breadcrumbs); return breadcrumbs; }
From source file:gov.nih.nci.cabig.caaers.domain.expeditedfields.UnsatisfiedProperty.java
/** * This method will return a qualified display name. * ie. displayname [parent]~displayname [current node] * * @return the display name/*from w w w . j a va2 s . com*/ */ public String getDisplayName() { ArrayList<String> displayNameList = new ArrayList<String>(); TreeNode node = treeNode; while (node != null && node instanceof PropertyNode && StringUtils.isNotEmpty(node.getDisplayName())) { displayNameList.add(node.getDisplayName()); node = node.getParent(); } Collections.reverse(displayNameList); return StringUtils.join(displayNameList, "~"); }
From source file:com.github.springtestdbunit.TestExecutionListenerChain.java
public TestExecutionListenerChain() { this.chain = createChain(); this.reverseChain = new ArrayList<TestExecutionListener>(this.chain); Collections.reverse(this.reverseChain); }
From source file:br.usp.poli.lta.cereda.aa.utils.SetOperations.java
/** * Calcula o produto cartesiano de um vetor de conjuntos. * @param sets Vetor de conjuntos.//from w w w . j a v a2 s . c om * @return Produto cartesiano do vetor de conjuntos. */ public static Set<List<Object>> cartesianProduct(Set<?>... sets) { // deve haver mais do que um conjunto Validate.isTrue(sets.length > 1, "No possvel calcular o produto cartesiano " + "de apenas um conjunto."); // nenhum conjunto pode ser vazio for (Set<?> set : sets) { Validate.isTrue(!set.isEmpty(), "No possvel calcular o produto cartesiano " + "quando um dos conjuntos vazio."); } // calcula o produto cartesiano Set<List<Object>> elements = fetchElements(0, sets); // o retorno da funo gera listas com elementos em ordem // reversa, portanto, necessrio inverter os elementos das // listas obtidas Set<List<Object>> result = new HashSet<>(); for (List<Object> list : elements) { Collections.reverse(list); result.add(list); } return result; }
From source file:net.javacrumbs.codecamp.common.CsvFileLogger.java
@Override public List<Message> getMessages() { try (CSVParser parser = CSVFormat.RFC4180.parse(new FileReader(file))) { List<Message> result = parser.getRecords().stream().map(CsvFileLogger::parseRecord).collect(toList()); Collections.reverse(result); return result; } catch (FileNotFoundException e) { return emptyList(); } catch (IOException e) { throw new IllegalStateException(e); }//from w ww .j a va2 s .c o m }
From source file:com.eatnumber1.util.io.FileUtils.java
@NotNull private static List<File> getFileElements(@NotNull File f) { List<File> cachedDirs = fileElementCache.get(f); if (cachedDirs != null) return cachedDirs; List<File> dirs = new LinkedList<File>(); File dir = f.getParentFile(); while (dir != null) { dirs.add(dir);/*from w w w . j ava2 s. c o m*/ dir = dir.getParentFile(); } Collections.reverse(dirs); dirs = Collections.unmodifiableList(dirs); fileElementCache.put(f, dirs); return dirs; }
From source file:com.ms.commons.test.math.expression.util.MathExpressionParseUtil.java
private static Stack<String> adjustExpressionStack(Stack<String> expressionStack) { if (expressionStack.size() <= 2) { return expressionStack; }//from w ww .j av a 2 s . c om int lastOpPr = Integer.MAX_VALUE; int lowerPrOp = -1; for (int i = (expressionStack.size() - 1); i >= 0; i--) { String expr = expressionStack.get(i); if ((expr.length() == 1) && hasSeparators(expr)) { int opPr = ("*".equals(expr) || "/".equals(expr)) ? 2 : 1; if (opPr < lastOpPr) { lastOpPr = opPr; lowerPrOp = i; } } } if (lowerPrOp != -1) { Stack<String> tempStack = new Stack<String>(); int popCount = expressionStack.size() - lowerPrOp - 1; for (int i = 0; i < popCount; i++) { tempStack.push(expressionStack.pop()); } Collections.reverse(tempStack); expressionStack.push(StringUtils.join(tempStack, "")); } return expressionStack; }
From source file:net.javacrumbs.codecamp.boot.common.CsvFileLogger.java
@Override @Cacheable(value = "messages", key = "'messages'") public List<Message> getMessages() { try (CSVParser parser = CSVFormat.RFC4180.parse(new FileReader(file))) { List<Message> result = parser.getRecords().stream().map(CsvFileLogger::parseRecord).collect(toList()); Collections.reverse(result); return result; } catch (FileNotFoundException e) { return emptyList(); } catch (IOException e) { throw new IllegalStateException(e); }//from ww w . ja v a 2s .c o m }
From source file:whitelabel.cloud.webapp.impl.service.LogAndJobService.java
public LogAndJob load() { LogAndJob logAndJob = new LogAndJob(); AppVirtualDatacenter vdc = loadDatacenter(); List<AppJob> jobs = null; List<AppLog> logs = null; WsEndUserClient wsClient = UserUtil.getWsEndUserClient(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, -7); List<AppLog> tmp = wsClient.getLogs(null, cal.getTime(), null); if (tmp != null) { Collections.reverse(tmp); logs = tmp;// ww w . jav a 2 s. c o m } List<AppJob> tmp2 = wsClient.getJobs(); if (tmp2 != null) { jobs = tmp2; } if (jobs == null) { jobs = new ArrayList<AppJob>(); } if (logs == null) { logs = new ArrayList<AppLog>(); } logAndJob.setLogs(logs); logAndJob.setJobs(jobs); return logAndJob; }
From source file:fr.jetoile.hadoopunit.HadoopBootstrap.java
HadoopBootstrap() { commands.clear();//from ww w . j a v a 2 s . c om commandLoader.reload(); Iterator<Bootstrap> commandsIterator = commandLoader.iterator(); while (commandsIterator.hasNext()) { Bootstrap command = commandsIterator.next(); commands.put(command.getName(), command); } Arrays.asList(Component.values()).stream().forEach(c -> { if (commands.containsKey(c.name())) { componentsToStart.add(commands.get(c.name())); } }); componentsToStop = Lists.newArrayList(this.componentsToStart); Collections.reverse(componentsToStop); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { LOGGER.info("All services are going to be stopped"); stopAll(); } }); }