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:org.solmix.runtime.support.spring.SpringBeanProvider.java
/** * {@inheritDoc}//from www .j a v a 2s. c o m * * @see org.solmix.api.bean.ConfiguredBeanProvider#loadBeansOfType(java.lang.Class, * org.solmix.api.bean.ConfiguredBeanProvider.BeanLoaderListener) */ @Override public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) { List<String> list = new ArrayList<String>(Arrays.asList(context.getBeanNamesForType(type, false, false))); list.removeAll(passThroughs); Collections.reverse(list); boolean loaded = false; for (String s : list) { Class<?> beanType = context.getType(s); Class<? extends T> t = beanType.asSubclass(type); if (listener.loadBean(s, t)) { Object o = context.getBean(s); if (listener.beanLoaded(s, type.cast(o))) { return true; } loaded = true; } } return loaded || original.loadBeansOfType(type, listener); }
From source file:qmul.align.AlignmentTester.java
/** * Process a single dialogue//w ww .ja v a2s .co m * * @param d * the dialogue to process * @param wb * the XLS workbook to write to, or null not to bother * @return a list of {@link Double} scores, one per {@link DialogueWindower} step (e.g. dialogue turn) */ public List<Double> processDialogue(Dialogue d, Workbook wb, HashMap<String, ArrayList<Double>> speakerScores, HashMap<String, String> originalSpks, HashMap<String, ArrayList<Double>> speakerN, MetricsMap spkMetrics, MetricsMap totMetrics, Workbook wbcounts, HashMap<String, HashMap<Object, Integer>> allCounts, HashMap<String, HashMap<Object, Integer>> commonCounts, HashMap<Object, Integer> diaAllCounts, HashMap<Object, Integer> diaCommonCounts) { CreationHelper creationHelper = wb.getCreationHelper(); win.setDialogue(d); sim.reset(); ArrayList<DialogueSpeaker> spks = new ArrayList<DialogueSpeaker>(d.getSpeakers()); Collections.sort(spks); Sheet sheet = (wb == null ? null : wb.createSheet(d.getId().replaceAll(":", "-"))); Sheet sheetcounts = (wbcounts == null ? null : wbcounts.createSheet(d.getId().replaceAll(":", "-"))); int iRow = 0; if (sheet != null) { iRow = writeSheetHeader(creationHelper, sheet, iRow, d, spks); } int iCRow = 0; if (sheetcounts != null) { iCRow = writeSheetHeader(creationHelper, sheet, iCRow, d, spks); } ArrayList<Double> scores = new ArrayList<Double>(); HashSet<X> counted = new HashSet<X>(); do { List<X> left = win.getLeftWindow(); Collections.reverse(left); // windowers return things in dialogue order: we'll look progressively backwards List<X> right = win.getRightWindow(); // System.out.println("lengthS " + left.size() + " " + right.size()); double score = 0.0; double n = 0.0; for (X r : right) { String spkKey = makeSpkKey(r.getSpeaker(), d); String originalSpkKey = ""; if (r.getOriginalSpeaker() != null) { originalSpkKey = r.getOriginalSpeaker().getId(); // fix for the fact that BNC speakers are not currently given SUBdialogue ID in their ID - TODO // change that? Dialogue od = r.getOriginalDialogue(); if ((od == null) && (r instanceof DialogueSentence)) { od = ((DialogueSentence) r).getTurn().getOriginalDialogue(); } String originalDia; if (od != null) { originalDia = od.getId(); } else { originalDia = d.getId().replaceFirst("-\\d+$", ""); } if (!originalSpkKey.contains(originalDia)) { if (!originalDia.contains(":")) { throw new RuntimeException("can't find super-dialogue, no : in " + originalDia); } String originalSuperDia = originalDia.substring(0, originalDia.lastIndexOf(":")); if (originalSpkKey.contains(originalSuperDia)) { originalSpkKey = originalSpkKey.replace(originalSuperDia, originalDia); } else { throw new RuntimeException("spk key without super-dialogue " + spkKey + ", " + originalSpkKey + ", " + originalDia); } } } Row row = (wb == null ? null : sheet.createRow(iRow++)); int iCol = 0; Cell cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_STRING)); if (cell != null) { cell.setCellValue(creationHelper.createRichTextString(r.getSpeaker().getId())); cell = row.createCell(iCol++, Cell.CELL_TYPE_STRING); cell.setCellValue(creationHelper.createRichTextString(originalSpkKey)); // cell = row.createCell(iCol++, Cell.CELL_TYPE_STRING); // cell.setCellValue(creationHelper.createRichTextString(r.getId())); cell = row.createCell(iCol++, Cell.CELL_TYPE_STRING); cell.setCellValue(creationHelper.createRichTextString(r.toString())); row.setHeightInPoints(12); sheet.setColumnWidth(iCol - 1, 2560); } if (!speakerScores.containsKey(spkKey)) { speakerScores.put(spkKey, new ArrayList<Double>()); speakerN.put(spkKey, new ArrayList<Double>()); originalSpks.put(spkKey, originalSpkKey); for (int i = 0; i < win.getLeftWindowSize(); i++) { speakerScores.get(spkKey).add(0.0); speakerN.get(spkKey).add(0.0); } Boolean isTurns = null; if (left.size() > 0) { isTurns = (left.get(0) instanceof DialogueTurn); } else if (right.size() > 0) { isTurns = (right.get(0) instanceof DialogueTurn); } spkMetrics.setNumUnits(spkKey, 0); totMetrics.setNumUnits(d.getId(), (isTurns ? d.numTurns() : d.numSents())); spkMetrics.setNumWords(spkKey, 0); totMetrics.setNumWords(d.getId(), d.numWords()); spkMetrics.setNumTokens(spkKey, 0); totMetrics.setNumTokens(d.getId(), d.numTokens()); } int iLeft = 0; double offset = Double.NaN; boolean gotOffset = false; for (X l : left) { double s = sim.similarity(l, r); // System.out.println("Siml = " + s + " for l:" + l.getId() + " r:" + r.getId()); if ((l.getOriginalId() != null) && (r.getOriginalId() != null) && l.getOriginalId().equals(r.getOriginalId())) { System.out.println("Equal IDs sim = " + s + " for l:" + l.getId() + " " + l.getOriginalId() + " r:" + r.getId() + " " + r.getOriginalId() + " d " + d.getId() + " nturns " + d.numTurns()); } if (wbcounts != null) { if (!counted.contains(l)) { MapUtil.addAll(diaAllCounts, sim.rawCountsA()); MapUtil.addAll(allCounts.get(""), sim.rawCountsA()); MapUtil.addAll(allCounts.get(d.getGenre()), sim.rawCountsA()); counted.add(l); } if (!counted.contains(r)) { MapUtil.addAll(diaAllCounts, sim.rawCountsB()); MapUtil.addAll(allCounts.get(""), sim.rawCountsB()); MapUtil.addAll(allCounts.get(d.getGenre()), sim.rawCountsB()); counted.add(r); } MapUtil.addAll(diaCommonCounts, sim.rawCountsAB()); MapUtil.addAll(commonCounts.get(""), sim.rawCountsAB()); MapUtil.addAll(commonCounts.get(d.getGenre()), sim.rawCountsAB()); } cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); if (cell != null) { cell.setCellValue(s); } score += s; n++; speakerScores.get(spkKey).set(iLeft, speakerScores.get(spkKey).get(iLeft) + s); speakerN.get(spkKey).set(iLeft, speakerN.get(spkKey).get(iLeft) + 1); if (!win.getClass().toString().contains("AllOther")) { // for "all other" windowers, actually // average over "window" iLeft++; } if (!gotOffset) { offset = r.getStartTime() - l.getEndTime(); gotOffset = true; // if (!Double.isNaN(offset)) { // System.out.println("Offset = " + offset + " for l:" + l.getId() + " r:" + r.getId()); // } } } // print number sents/words/tokens iCol += (win.getLeftWindowSize() - left.size() + 1); if (wb != null) { // if we are writing to a workbook cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); cell.setCellValue(r instanceof DialogueTurn ? ((DialogueTurn) r).getSents().size() : 1); cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); cell.setCellValue(r.numWords()); cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); cell.setCellValue(r.numTokens()); } iCol += 1; if (!Double.isNaN(offset)) { cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); cell.setCellValue(offset); } else { iCol++; } double wordRate = (double) (r.getEndTime() - r.getStartTime()) / (double) r.numWords(); if (r.numWords() == 0) { wordRate = Double.NaN; // on some OSs this doesn't happen in the calc above } if (!Double.isNaN(wordRate)) { cell = (wb == null ? null : row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC)); cell.setCellValue(wordRate); } else { iCol++; } // make sure we counted this one - the first one can get missed if leftWindow empty if ((wbcounts != null) && !counted.contains(r)) { sim.similarity(r, r); MapUtil.addAll(diaAllCounts, sim.rawCountsA()); MapUtil.addAll(allCounts.get(""), sim.rawCountsA()); MapUtil.addAll(allCounts.get(d.getGenre()), sim.rawCountsA()); counted.add(r); } spkMetrics.setNumUnits(spkKey, spkMetrics.getNumUnits(spkKey) + 1); spkMetrics.setNumWords(spkKey, spkMetrics.getNumWords(spkKey) + r.numWords()); spkMetrics.setNumTokens(spkKey, spkMetrics.getNumTokens(spkKey) + r.numTokens()); if (!Double.isNaN(offset)) { spkMetrics.setTurnOffset(spkKey, spkMetrics.getTurnOffset(spkKey) + offset); spkMetrics.setNumTurnOffsets(spkKey, spkMetrics.getNumTurnOffsets(spkKey) + 1); totMetrics.setTurnOffset(d.getId(), totMetrics.getTurnOffset(d.getId()) + offset); totMetrics.setNumTurnOffsets(d.getId(), totMetrics.getNumTurnOffsets(d.getId()) + 1); } if (!Double.isNaN(wordRate)) { spkMetrics.setWordRate(spkKey, spkMetrics.getWordRate(spkKey) + wordRate); spkMetrics.setNumWordRates(spkKey, spkMetrics.getNumWordRates(spkKey) + 1); totMetrics.setWordRate(d.getId(), totMetrics.getWordRate(d.getId()) + wordRate); totMetrics.setNumWordRates(d.getId(), totMetrics.getNumWordRates(d.getId()) + 1); } } scores.add((n == 0.0) ? 0.0 : (score / n)); } while (win.advance()); if (wb != null) { iRow++; for (DialogueSpeaker spk : spks) { String spkKey = makeSpkKey(spk, d); Row row = sheet.createRow(iRow++); int iCol = 0; row.createCell(iCol++, Cell.CELL_TYPE_STRING) .setCellValue(creationHelper.createRichTextString(spk.getId())); row.createCell(iCol++, Cell.CELL_TYPE_STRING) .setCellValue(creationHelper.createRichTextString(originalSpks.get(spkKey))); row.createCell(iCol++, Cell.CELL_TYPE_STRING) .setCellValue(creationHelper.createRichTextString("Mean")); for (int i = 0; i < win.getLeftWindowSize(); i++) { if (speakerN.get(spkKey).get(i) > 0) { row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC) .setCellValue(speakerScores.get(spkKey).get(i) / speakerN.get(spkKey).get(i)); } else { iCol++; } // System.out // .println("score " + i + " for speaker " + spkKey + "=" + speakerScores.get(spkKey).get(i)); // System.out.println("N " + i + " for speaker " + spkKey + "=" + speakerN.get(spkKey).get(i)); // System.out.println("mean " + i + " for speaker " + spkKey + "=" // + (speakerScores.get(spkKey).get(i) / speakerN.get(spkKey).get(i))); } iCol++; row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC).setCellValue( (double) spkMetrics.getNumUnits(spkKey) / (double) spkMetrics.getNumUnits(spkKey)); row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC).setCellValue( (double) spkMetrics.getNumWords(spkKey) / (double) spkMetrics.getNumUnits(spkKey)); row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC).setCellValue( (double) spkMetrics.getNumTokens(spkKey) / (double) spkMetrics.getNumUnits(spkKey)); iCol++; row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC).setCellValue( (double) spkMetrics.getTurnOffset(spkKey) / (double) spkMetrics.getNumTurnOffsets(spkKey)); row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC).setCellValue( (double) spkMetrics.getWordRate(spkKey) / (double) spkMetrics.getNumWordRates(spkKey)); } } if (wbcounts != null) { iCRow++; ArrayList<Object> keys = new ArrayList<Object>(diaAllCounts.keySet()); Collections.sort(keys, new DescendingComparator<Object>(diaAllCounts)); for (Object key : keys) { Row row = sheetcounts.createRow(iCRow++); int iCol = 0; row.createCell(iCol++, Cell.CELL_TYPE_STRING) .setCellValue(creationHelper.createRichTextString(key.toString())); Cell cell = row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC); if (diaAllCounts.get(key) != null) { cell.setCellValue(diaAllCounts.get(key)); } cell = row.createCell(iCol++, Cell.CELL_TYPE_NUMERIC); if (diaCommonCounts.get(key) != null) { cell.setCellValue(diaCommonCounts.get(key)); } } } return scores; }
From source file:lisong_mechlab.view.graphs.SustainedDpsGraph.java
private TableXYDataset getSeries() { final Collection<Modifier> modifiers = loadout.getModifiers(); SortedMap<Weapon, List<Pair<Double, Double>>> data = new TreeMap<Weapon, List<Pair<Double, Double>>>( new Comparator<Weapon>() { @Override/*www. jav a 2 s . c o m*/ public int compare(Weapon aO1, Weapon aO2) { int comp = Double.compare(aO2.getRangeMax(modifiers), aO1.getRangeMax(modifiers)); if (comp == 0) return aO1.compareTo(aO2); return comp; } }); Double[] ranges = WeaponRanges.getRanges(loadout); for (double range : ranges) { Set<Entry<Weapon, Double>> damageDistributio = maxSustainedDPS.getWeaponRatios(range).entrySet(); for (Map.Entry<Weapon, Double> entry : damageDistributio) { final Weapon weapon = entry.getKey(); final double ratio = entry.getValue(); final double dps = weapon.getStat("d/s", modifiers); final double rangeEff = weapon.getRangeEffectivity(range, modifiers); if (!data.containsKey(weapon)) { data.put(weapon, new ArrayList<Pair<Double, Double>>()); } data.get(weapon).add(new Pair<Double, Double>(range, dps * ratio * rangeEff)); } } List<Weapon> orderedWeapons = new ArrayList<>(); DefaultTableXYDataset dataset = new DefaultTableXYDataset(); for (Map.Entry<Weapon, List<Pair<Double, Double>>> entry : data.entrySet()) { XYSeries series = new XYSeries(entry.getKey().getName(), true, false); for (Pair<Double, Double> pair : entry.getValue()) { series.add(pair.first, pair.second); } dataset.addSeries(series); orderedWeapons.add(entry.getKey()); } Collections.reverse(orderedWeapons); colours.updateColoursToMatch(orderedWeapons); return dataset; }
From source file:com.logsniffer.web.controller.source.LogEntriesRestController.java
@RequestMapping(value = "/sources/entries", method = RequestMethod.POST) @ResponseBody//from ww w . j a v a 2 s . com LogEntriesResult getEntries( @Valid @RequestBody final LogSource<LogRawAccess<? extends LogInputStream>> activeLogSource, @RequestParam("log") final String logPath, @RequestParam(value = "mark", required = false) final String mark, @RequestParam(value = "count") final int count) throws IOException, FormatException, ResourceNotFoundException { logger.debug("Start load entries log={} from source={}, mark={}, count={}", logPath, activeLogSource, mark, count); try { final Log log = getLog(activeLogSource, logPath); LogPointer pointer = null; final LogRawAccess<? extends LogInputStream> logAccess = activeLogSource.getLogAccess(log); if (StringUtils.isNotEmpty(mark)) { pointer = logAccess.getFromJSON(mark); } else { if (count < 0) { // Tail pointer = logAccess.end(); } } if (count > 0) { final BufferedConsumer bc = new BufferedConsumer(count); activeLogSource.getReader().readEntries(log, logAccess, pointer, bc); return new LogEntriesResult(activeLogSource.getReader().getFieldTypes(), bc.getBuffer(), getHighlightEntryIndex(pointer, count, bc.getBuffer())); } else { final BufferedConsumer bc = new BufferedConsumer(-count); activeLogSource.getReader().readEntriesReverse(log, logAccess, pointer, bc); final List<LogEntry> readEntries = bc.getBuffer(); Collections.reverse(readEntries); return new LogEntriesResult(activeLogSource.getReader().getFieldTypes(), readEntries, getHighlightEntryIndex(pointer, count, readEntries)); } } finally { logger.debug("Finished log entries from log={} and source={}", logPath, activeLogSource); } }
From source file:com.netflix.curator.x.discovery.TestServiceDiscovery.java
@Test public void testCrashedInstance() throws Exception { List<Closeable> closeables = Lists.newArrayList(); TestingServer server = new TestingServer(); closeables.add(server);//from w w w.j av a2 s.com try { Timing timing = new Timing(); CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), timing.connection(), new RetryOneTime(1)); closeables.add(client); client.start(); ServiceInstance<String> instance = ServiceInstance.<String>builder().payload("thing").name("test") .port(10064).build(); ServiceDiscovery<String> discovery = new ServiceDiscoveryImpl<String>(client, "/test", new JsonInstanceSerializer<String>(String.class), instance); closeables.add(discovery); discovery.start(); Assert.assertEquals(discovery.queryForInstances("test").size(), 1); KillSession.kill(client.getZookeeperClient().getZooKeeper(), server.getConnectString()); Thread.sleep(timing.multiple(1.5).session()); Assert.assertEquals(discovery.queryForInstances("test").size(), 1); } finally { Collections.reverse(closeables); for (Closeable c : closeables) { IOUtils.closeQuietly(c); } } }
From source file:com.github.panthers.maven.plugins.fromConfig.AbstractFromConfigMojo.java
/** * Returns the available versions of the artifact of the given range. * Filtered based on configuration/* w w w.j a v a 2 s. c o m*/ * @param artifactItemsWithRange * @return * @throws MojoExecutionException */ @SuppressWarnings("unchecked") private List<DefaultArtifactVersion> getAvailableVersions(ArtifactItemsWithRange artifactItemsWithRange) throws MojoExecutionException { VersionRange artifactVersionRange; try { artifactVersionRange = VersionRange.createFromVersionSpec(artifactItemsWithRange.getVersionRange()); } catch (InvalidVersionSpecificationException e) { throw new MojoExecutionException("Version range is invalid."); } Artifact artifact; if (StringUtils.isEmpty(artifactItemsWithRange.getClassifier())) { artifact = factory.createDependencyArtifact(artifactItemsWithRange.getGroupId(), artifactItemsWithRange.getArtifactId(), artifactVersionRange, artifactItemsWithRange.getType(), artifactItemsWithRange.getClassifier(), Artifact.SCOPE_COMPILE); } else { artifact = factory.createDependencyArtifact(artifactItemsWithRange.getGroupId(), artifactItemsWithRange.getArtifactId(), artifactVersionRange, artifactItemsWithRange.getType(), null, Artifact.SCOPE_COMPILE); } List<DefaultArtifactVersion> availableVersions = new ArrayList<DefaultArtifactVersion>(); try { List<DefaultArtifactVersion> allVersions = artifactMetadataSource.retrieveAvailableVersions(artifact, local, remoteRepos); if (artifactItemsWithRange.getIncludeSnapshots()) { availableVersions.addAll(allVersions); getLog().debug("Adding all versions " + allVersions.toString()); } else { Collections.sort(allVersions); Collections.reverse(allVersions); if ("SNAPSHOT".equals(allVersions.get(0).getQualifier()) && artifactItemsWithRange.getIncludeLatestSnapshot()) { //If latest is snapshot and include latest exists add this availableVersions.add(allVersions.get(0)); } else if (!"SNAPSHOT".equals(allVersions.get(0).getQualifier())) { availableVersions.add(allVersions.get(0)); } for (int i = 1; i < allVersions.size(); i++) { //Get all other artifacts without snapshot if (!"SNAPSHOT".equals(allVersions.get(i).getQualifier())) { availableVersions.add(allVersions.get(i)); } } } } catch (ArtifactMetadataRetrievalException e) { throw new MojoExecutionException("Could not retrieve available versions"); } getLog().debug("Final versions to process : " + availableVersions.toString()); return availableVersions; }
From source file:org.jahia.modules.defaultmodule.RolesHandler.java
public Map<JCRNodeWrapper, List<JCRNodeWrapper>> getRoles() throws Exception { Map<String, JCRNodeWrapper> rolesFromName = new HashMap<String, JCRNodeWrapper>(); Map<JCRNodeWrapper, List<JCRNodeWrapper>> result = new TreeMap<JCRNodeWrapper, List<JCRNodeWrapper>>( new Comparator<JCRNodeWrapper>() { @Override//from ww w . j a va2 s . c om public int compare(JCRNodeWrapper jcrNodeWrapper, JCRNodeWrapper jcrNodeWrapper2) { return jcrNodeWrapper.getDisplayableName().compareTo(jcrNodeWrapper2.getDisplayableName()); } }); final JCRSessionWrapper defaultSession = JCRSessionFactory.getInstance().getCurrentUserSession(null, locale, fallbackLocale); QueryManager qm = defaultSession.getWorkspace().getQueryManager(); if (role != null) { Query q = qm.createQuery( "select * from [jnt:role] where localname()='" + JCRContentUtils.sqlEncode(role) + "'", Query.JCR_SQL2); getRoles(q, rolesFromName, result); } else if (roles == null) { Query q = qm.createQuery( "select * from [jnt:role] where [j:roleGroup]='" + JCRContentUtils.sqlEncode(roleGroup) + "'", Query.JCR_SQL2); getRoles(q, rolesFromName, result); } else { for (String r : roles) { Query q = qm.createQuery( "select * from [jnt:role] where localname()='" + JCRContentUtils.sqlEncode(r) + "'", Query.JCR_SQL2); getRoles(q, rolesFromName, result); } } final JCRSessionWrapper s = JCRSessionFactory.getInstance().getCurrentUserSession(workspace, locale, fallbackLocale); JCRNodeWrapper node = s.getNode(nodePath); Map<String, List<String[]>> acl = node.getAclEntries(); String siteKey = nodePath.startsWith("/sites/") ? StringUtils.substringBefore(StringUtils.substringAfter(nodePath, "/sites/"), "/") : null; for (Map.Entry<String, List<String[]>> entry : acl.entrySet()) { JCRNodeWrapper p = null; if (entry.getKey().startsWith("u:")) { p = userManagerService.lookupUser(entry.getKey().substring(2), siteKey); } else if (entry.getKey().startsWith("g:")) { if (siteKey != null) { p = groupManagerService.lookupGroup(siteKey, entry.getKey().substring(2)); } if (p == null) { p = groupManagerService.lookupGroup(null, entry.getKey().substring(2)); } } if (p != null) { final List<String[]> value = entry.getValue(); Collections.reverse(value); for (String[] strings : value) { String role = strings[2]; if (strings[1].equals("GRANT") && rolesFromName.containsKey(role) && !result.get(rolesFromName.get(role)).contains(p)) { result.get(rolesFromName.get(role)).add(p); } else if (strings[1].equals("DENY") && rolesFromName.containsKey(role)) { result.get(rolesFromName.get(role)).remove(p); } } } } return result; }
From source file:com.silverpeas.look.SilverpeasLook.java
/** * return the CSS URL of space with a specific CSS. This space can be the given space itself or one * of its parents. It is this URL which must be applied to given space. * @param spaceId/*from ww w . java 2s . co m*/ * @return the CSS URL of first space (from given space to root) with a specific CSS. If no space * in path have got specific CSS, returns null. */ public String getCSSOfSpace(String spaceId) { List<SpaceInst> path = organizationController.getSpacePath(spaceId); Collections.reverse(path); for (SpaceInst space : path) { String url = getSpaceCSSURL(space.getId()); if (isDefined(url)) { return url; } } return null; }
From source file:com.ofalvai.bpinfo.ui.alertlist.AlertListPresenter.java
/** * Returns a new filtered list of Alerts matching the provided set of RouteTypes, and sorted * according to the alert list type (descending/ascending) *//*from w w w . j av a 2 s . c o m*/ @NonNull private static List<Alert> filterAndSort(@Nullable Set<RouteType> types, @NonNull List<Alert> alerts, @NonNull AlertListType type) { List<Alert> sorted = new ArrayList<>(alerts); // Sort: descending by alert start time Collections.sort(sorted, new Utils.AlertStartTimestampComparator()); if (type == AlertListType.ALERTS_TODAY) { Collections.reverse(sorted); } if (types == null || types.isEmpty()) { return sorted; } List<Alert> filtered = new ArrayList<>(); for (Alert alert : sorted) { for (Route route : alert.getAffectedRoutes()) { if (types.contains(route.getType())) { filtered.add(alert); break; } } } return filtered; }
From source file:com.griddynamics.banshun.ContextParentBean.java
public void destroy() throws Exception { Collections.reverse(children); for (ConfigurableApplicationContext child : children) { child.close();/*from w ww . j a v a 2 s . com*/ } }