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.glowroot.transaction.model.Traverser.java
@SuppressWarnings("unchecked") void traverse() throws IOException { while (!stack.isEmpty()) { Object popped = stack.pop(); if (popped == ALREADY_TRAVERSED_MARKER) { revisitAfterChildren((T) stack.pop()); continue; }/*from ww w . ja v a 2 s . c o m*/ T unprocessed = (T) popped; List<T> childNodes = visit(unprocessed); if (childNodes.isEmpty()) { // optimization for no children revisitAfterChildren(unprocessed); } else { stack.push(unprocessed); stack.push(ALREADY_TRAVERSED_MARKER); for (T childNode : Lists.reverse(childNodes)) { stack.push(childNode); } } } }
From source file:com.torodb.core.bundle.DependenciesBundle.java
@Override protected void preDependenciesShutDown() throws Exception { for (Service managedDependency : Lists.reverse(getManagedDependencies())) { managedDependency.stopAsync();/*from w w w. j a v a2 s. c om*/ managedDependency.awaitTerminated(); } }
From source file:com.helion3.prism.commands.UndoCommand.java
public static CommandSpec getCommand() { return CommandSpec.builder().permission("prism.undo").executor((source, args) -> { if (!(source instanceof Player)) { throw new CommandException(Format.error("You must be a player to use this command.")); }//from w ww. j a va2 s . c om List<ActionableResult> results = Prism.getLastActionResults().get(((Player) source).getUniqueId()); if (results == null || results.isEmpty()) { throw new CommandException(Format.error("You have no valid actions to undo.")); } // Reverse the order of the list to undo last action. results = Lists.reverse(results); int applied = 0; int skipped = 0; for (ActionableResult result : results) { if (result.getTransaction().isPresent()) { Object rawOriginal = result.getTransaction().get().getOriginal(); Object rawFinal = result.getTransaction().get().getFinal(); if (rawOriginal instanceof BlockSnapshot) { if (((BlockSnapshot) rawOriginal).restore(true, BlockChangeFlag.NONE)) { applied++; } else { skipped++; } } if (rawFinal instanceof Entity) { Entity entity = (Entity) rawFinal; if (!entity.isRemoved()) { entity.remove(); applied++; } else { skipped++; } } } else { skipped++; } } Map<String, String> tokens = new HashMap<>(); tokens.put("appliedCount", "" + applied); tokens.put("skippedCount", "" + skipped); final String messageTemplate; if (skipped > 0) { messageTemplate = Translation.from("rollback.success.withskipped"); } else { messageTemplate = Translation.from("rollback.success"); } source.sendMessage(Format.heading(Text.of(Template.parseTemplate(messageTemplate, tokens)), " ", Format.bonus(Translation.from("rollback.success.bonus")))); return CommandResult.success(); }).build(); }
From source file:com.aionlightning.commons.scripting.classlistener.AggregatedClassListener.java
@Override public void preUnload(Class<?>[] classes) { for (ClassListener cl : Lists.reverse(getClassListeners())) { cl.preUnload(classes); } }
From source file:org.caleydo.core.view.opengl.util.spline.Band.java
public Band(List<Vec3f> curveTop, List<Vec3f> curveBottom) { this.curveTop = curveTop; // create a reversed ordered version for simpler handling this.curveBottom = Lists.reverse(curveBottom); }
From source file:org.robotframework.ide.eclipse.main.plugin.model.cmd.variables.MoveDictVariableValueElementsCommand.java
@Override public void execute() throws CommandExecutionException { if (variable.getType() != VariableType.DICTIONARY) { throw new CommandExecutionException("Variables of type " + variable.getType() + " cannot have their value elements moved with this command"); }/*from w w w. j a v a 2s . c om*/ final List<DictionaryKeyValuePair> elements = direction == MoveDirection.UP ? elementsToMove : Lists.reverse(elementsToMove); final DictionaryVariable dictVariable = (DictionaryVariable) variable.getLinkedElement(); for (final DictionaryKeyValuePair detailToMove : elements) { if (direction == MoveDirection.UP) { dictVariable.moveLeftKeyValuePair(detailToMove); } else { dictVariable.moveRightKeyValuePair(detailToMove); } } eventBroker.send(RobotModelEvents.ROBOT_VARIABLE_VALUE_CHANGE, variable); }
From source file:org.gradle.integtests.fixtures.ReleasedVersions.java
public BasicGradleDistribution getPreviousOf(BasicGradleDistribution distro) { GradleVersion distroVersion = GradleVersion.version(distro.getVersion()); for (String candidate : Lists.reverse(RELEASED)) { GradleVersion candidateVersion = GradleVersion.version(candidate); if (distroVersion.compareTo(candidateVersion) > 0) { return current.previousVersion(candidate); }//w ww . j a va 2s.c o m } throw new RuntimeException("I don't know the previous version of: " + distro); }
From source file:da.RequestJpaController.java
public List<Request> getRequestsByResolver(String username, int type) { TypedQuery<Request> query = getEntityManager().createQuery( "SELECT r FROM Request r WHERE r.resolveAccount.username = :username AND r.type=:type ORDER BY r.time DESC", Request.class); query.setParameter("username", username); query.setParameter("type", type); return Lists.reverse(query.getResultList()); }
From source file:org.spongepowered.repoindexer.MustacheData.java
public MustacheData(String title, List<ResolvedArtifact> ra) { mfiles = Lists.newArrayList();/* w w w .j a v a 2s.c o m*/ System.out.println(ra.size()); this.title = title; for (ResolvedArtifact res : ra) { SuperStringPair ssp = res.getMainDownloadInfo(); //System.out.println(spairs.size()); mfiles.add(new MFile(ssp)); } mfiles = Lists.reverse(mfiles); System.out.println(mfiles.size()); DateFormat df = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, new Locale("en", "EN")); date = df.format(new Date()); }
From source file:org.kie.io.EntryRecorder.java
void overrideExistingEntries(final List<Entry> entryList) { final List<Entry> entries = Lists.reverse(entryList); pagination.paginate(entries, (index, page) -> { try {/*www . ja v a 2s . com*/ new EntryWriter(fileName).record(index, page); } catch (IOException e) { e.printStackTrace(); } }); }