List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:org.opendaylight.netconf.cli.reader.custom.FilterReader.java
@Override protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode) throws IOException, ReadingException { boolean redSuccessfuly = false; DataContainerChild<?, ?> newNode = null; do {/*from w w w . ja va 2 s.c o m*/ console.writeLn("Filter " + schemaNode.getQName().getLocalName()); console.writeLn("Submit path of the data to retrieve. Use TAB for autocomplete"); final String rawValue = console.read(); // FIXME skip should be somewhere in abstractReader if (isSkipInput(rawValue) || Strings.isNullOrEmpty(rawValue)) { return Collections.emptyList(); } final List<QName> filterPartsQNames = Lists.newArrayList(); try { for (final String part : rawValue.split(SEPARATOR)) { final QName qName = IOUtil.qNameFromKeyString(part, mappedModules); filterPartsQNames.add(qName); } DataContainerChild<?, ?> previous = null; for (final QName qName : Lists.reverse(filterPartsQNames)) { previous = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(qName)) .withValue(previous == null ? Collections.<DataContainerChild<?, ?>>emptyList() : Collections.<DataContainerChild<?, ?>>singletonList(previous)) .build(); } final Map<QName, String> attributes = Collections.singletonMap(FILTER_TYPE_QNAME, FILTER_TYPE_VALUE_DEFAULT); newNode = previous == null ? null : ImmutableContainerNodeBuilder.create() .withNodeIdentifier(new NodeIdentifier(schemaNode.getQName())).withChild(previous) .build(); redSuccessfuly = true; } catch (final ReadingException e) { final String message = "Specified filter path isn't correct."; LOG.error(message, e); console.writeLn(message); } } while (!redSuccessfuly); return Collections.<NormalizedNode<?, ?>>singletonList(newNode); }
From source file:org.jenkinsci.plugins.jobgenerator.JobGenerator.java
/** * Returns plugin own parameter definition property which wraps the real * one.//from w w w . j a va2 s . co m */ @Override public <T extends JobProperty> T getProperty(Class<T> clazz) { T res = super.getProperty(clazz); if (ParametersDefinitionProperty.class == clazz) { ParametersDefinitionProperty topmost = (ParametersDefinitionProperty) this .getTopMostParameterDefinitionProperty(); if (res != null) { // wrap parameter definitions and merge with top most project // parameters GeneratorParametersDefinitionProperty newres = new GeneratorParametersDefinitionProperty( (ParametersDefinitionProperty) res, this); if (topmost != null) { List<ParameterDefinition> lpd = topmost.getParameterDefinitions(); for (ParameterDefinition pd : Lists.reverse(lpd)) { newres.getParameterDefinitions().add(0, pd); } newres.addGlobalParameters(lpd); lpd = ((ParametersDefinitionProperty) res).getParameterDefinitions(); newres.addLocalParameters(lpd); } else { List<ParameterDefinition> lpd = ((ParametersDefinitionProperty) res).getParameterDefinitions(); newres.addGlobalParameters(lpd); } res = (T) newres; } else if (topmost != null) { List<ParameterDefinition> lpd = topmost.getParameterDefinitions(); GeneratorParametersDefinitionProperty newres = new GeneratorParametersDefinitionProperty(topmost, this); newres.addGlobalParameters(lpd); newres.setOwner2(this); res = (T) newres; } } return res; }
From source file:org.gitools.heatmap.header.HierarchicalClusterHeatmapHeader.java
@Override public void populateDetails(List<DetailsDecoration> details, String identifier, boolean selected) { DetailsDecoration desiredDecoration = null; for (HeatmapColoredLabelsHeader level : Lists.reverse(clusterLevels)) { DetailsDecoration decoration = new DetailsDecoration(this.getTitle(), getDescription(), null, null, null);/*from w ww . j a v a 2s . c o m*/ decoration.setReference(this); if (identifier != null) { level.reset(); ColoredLabel cluster = level.getColoredLabel(identifier); Color clusterColor = cluster != null ? cluster.getColor() : getBackgroundColor(); decoration.setBgColor(clusterColor); if (!cluster.getDisplayedLabel().equals("")) { int levelIndex = clusterLevels.size() - clusterLevels.indexOf(level); decoration.setValue("L" + levelIndex + ": " + cluster.getDisplayedLabel()); desiredDecoration = decoration; } } if (isReportLastInteraction() && clusterLevels.indexOf(level) == interactionLevel) { break; } } if (desiredDecoration != null) { desiredDecoration.setSelected(selected); details.add(desiredDecoration); } }
From source file:co.cask.cdap.common.twill.AbstractMasterTwillRunnable.java
@Override public void run() { runThread = Thread.currentThread(); LOG.info("Starting runnable {}", name); SettableFuture<String> completionFuture = SettableFuture.create(); for (Service service : services) { service.addListener(createServiceListener(service.getClass().getName(), completionFuture), Threads.SAME_THREAD_EXECUTOR); }/*ww w. j av a 2 s . c o m*/ Services.chainStart(services.get(0), services.subList(1, services.size()).toArray(new Service[0])); LOG.info("Runnable started {}", name); try { // exit as soon as any service completes completionFuture.get(); } catch (InterruptedException e) { LOG.debug("Waiting on latch interrupted {}", name); Thread.currentThread().interrupt(); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } List<Service> reverse = Lists.reverse(services); Services.chainStop(reverse.get(0), reverse.subList(1, reverse.size()).toArray(new Service[0])); LOG.info("Runnable stopped {}", name); }
From source file:org.caleydo.view.crossword.api.ui.band.Route.java
@Override public void fill(GLGraphics g, TesselationRenderer renderer) { // render the shifted top curve concatenated with the reverse of the bottom curve renderer.render2(g, Iterables.concat(shiftCurve(radiusInterpolator), Lists.reverse(Lists.newArrayList(shiftCurve(negatedRadiusInterpolator()))))); }
From source file:org.sonar.server.qualityprofile.QProfileFactory.java
/** * Session is NOT committed. Profiles marked as "default" for a language can't be deleted, * except if the parameter <code>force</code> is true. *///from w ww.ja v a 2s . c o m public List<ActiveRuleChange> delete(DbSession session, String key, boolean force) { QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(session, key); List<QualityProfileDto> descendants = db.qualityProfileDao().selectDescendants(session, key); if (!force) { checkNotDefault(profile); for (QualityProfileDto descendant : descendants) { checkNotDefault(descendant); } } // delete bottom-up List<ActiveRuleChange> changes = new ArrayList<>(); for (QualityProfileDto descendant : Lists.reverse(descendants)) { changes.addAll(doDelete(session, descendant)); } changes.addAll(doDelete(session, profile)); return changes; }
From source file:com.teradata.tempto.internal.context.GuiceTestContext.java
@Override public void close() { copyOf(children).forEach(GuiceTestContext::close); Lists.reverse(closeCallbacks).forEach(callback -> callback.testContextClosed(this)); if (parent.isPresent()) { parent.get().children.remove(this); }//w w w . j a va2s . co m }
From source file:org.caleydo.view.bicluster.elem.AllClustersElement.java
private void focusPrevious(final List<NormalClusterElement> sortedClusters) { NormalClusterElement prev = null;//from w w w . java 2s.c om for (NormalClusterElement cluster : sortedClusters) { if (cluster.getDimSize() <= 0 || cluster.getRecSize() <= 0) continue; if (cluster == focussedElement && prev != null) { setFocus(prev); return; } prev = cluster; } // else use the last focussable one, round trip for (NormalClusterElement cluster : Lists.reverse(sortedClusters)) { if (cluster.getDimSize() <= 0 || cluster.getRecSize() <= 0) continue; if (cluster == focussedElement) break; setFocus(cluster); break; } }
From source file:guru.qas.martini.scope.ScenarioScope.java
protected void runDestructionCallbacks() { LinkedHashMap<String, Runnable> index = DESTRUCTION_CALLBACKS.get(); DESTRUCTION_CALLBACKS.remove();//ww w . j a v a2 s . c om List<String> names = Lists.reverse(Lists.newArrayList(index.keySet())); for (String name : names) { Runnable callback = index.remove(name); run(name, callback); } }
From source file:com.google.currysrc.api.process.ast.TypeLocator.java
@Override public boolean matches(BodyDeclaration node) { if (!(node instanceof AbstractTypeDeclaration)) { return false; }/* w w w .j a va 2s . co m*/ if (!packageMatcher.matches((CompilationUnit) node.getRoot())) { return false; } Iterable<String> reverseClassNames = Lists.reverse(classNameElements); Iterator<String> reverseClassNamesIterator = reverseClassNames.iterator(); return matchNested(reverseClassNamesIterator, (AbstractTypeDeclaration) node); }