List of usage examples for com.google.common.collect Lists reverse
@CheckReturnValue public static <T> List<T> reverse(List<T> list)
From source file:ijfx.core.io.IjfxRecentFileService.java
@Override public List<String> getRecentFiles() { List<String> recentFile = Lists.reverse(listPath); if (recentFile.size() > RECENT_FILE_DISPLAYED_LIMIT) { recentFile = recentFile.subList(0, 10); }//from w w w . j a v a 2 s . c o m return recentFile; }
From source file:free.rm.skytube.gui.businessobjects.BlockedVideosDialog.java
public BlockedVideosDialog(@NonNull final Context context, final BlockedVideosDialogListener blockedVideosDialogListener, final List<VideoBlocker.BlockedVideo> blockedVideos) { super(context); if (blockedVideos.isEmpty()) { // if no videos have been blocked, the ask the user is he wants to configure the // preferences of the video blocker... title(R.string.pref_video_blocker_category); content(R.string.no_videos_blocked); this.listener = null; } else {//from w ww .j ava 2s . c o m // display a list of blocked videos title(R.string.blocked_videos); adapter(new BlockedVideosAdapter(context, Lists.reverse(blockedVideos)), null); // invert the list of blocked videos neutralText(R.string.clear); onNeutral(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { if (listener != null) listener.onClearBlockedVideos(); } }); this.listener = blockedVideosDialogListener; } positiveText(R.string.configure); onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { // display the PreferenceActivity where the Videos Blocker tab is selected/opened // by default final Intent i = new Intent(context, PreferencesActivity.class); i.putExtra(EXTRA_SHOW_FRAGMENT, VideoBlockerPreferenceFragment.class.getName()); context.startActivity(i); } }); }
From source file:org.sonar.server.issue.notification.NewIssuesEmailTemplate.java
@Override public EmailMessage format(Notification notification) { if (!NewIssuesNotification.TYPE.equals(notification.getType())) { return null; }/*from w w w .ja v a2s .com*/ String projectName = notification.getFieldValue(FIELD_PROJECT_NAME); StringBuilder sb = new StringBuilder(); sb.append("Project: ").append(projectName).append("\n\n"); sb.append(notification.getFieldValue("count")).append(" new issues").append("\n\n"); sb.append(" "); for (Iterator<String> severityIterator = Lists.reverse(Severity.ALL).iterator(); severityIterator .hasNext();) { String severity = severityIterator.next(); String severityLabel = i18n.message(getLocale(), "severity." + severity, severity); sb.append(severityLabel).append(": ").append(notification.getFieldValue("count-" + severity)); if (severityIterator.hasNext()) { sb.append(" "); } } sb.append('\n'); appendFooter(sb, notification); return new EmailMessage().setMessageId("new-issues/" + notification.getFieldValue(FIELD_PROJECT_KEY)) .setSubject(projectName + ": new issues").setMessage(sb.toString()); }
From source file:org.apache.jackrabbit.oak.spi.commit.MoveTracker.java
@CheckForNull public String getSourcePath(String destPath) { for (MoveEntry me : Lists.reverse(entries)) { if (me.destPath.equals(destPath)) { return me.sourcePath; }// w w w . j av a 2 s . c o m } return null; }
From source file:org.sonar.plugins.core.issue.notification.NewIssuesEmailTemplate.java
@Override public EmailMessage format(Notification notification) { if (!"new-issues".equals(notification.getType())) { return null; }/*w w w .ja va2s.c om*/ String projectName = notification.getFieldValue(FIELD_PROJECT_NAME); StringBuilder sb = new StringBuilder(); sb.append("Project: ").append(projectName).append("\n\n"); sb.append(notification.getFieldValue("count")).append(" new issues").append("\n\n"); sb.append(" "); for (Iterator<String> severityIterator = Lists.reverse(Severity.ALL).iterator(); severityIterator .hasNext();) { String severity = severityIterator.next(); String severityLabel = i18n.message(getLocale(), "severity." + severity, severity); sb.append(severityLabel).append(": ").append(notification.getFieldValue("count-" + severity)); if (severityIterator.hasNext()) { sb.append(" "); } } sb.append('\n'); appendFooter(sb, notification); return new EmailMessage().setMessageId("new-issues/" + notification.getFieldValue(FIELD_PROJECT_KEY)) .setSubject(projectName + ": new issues").setMessage(sb.toString()); }
From source file:uk.ac.ebi.atlas.search.diffanalytics.DiffAnalyticsList.java
public double getMinDownRegulatedExpressionLevel() { if (minDownRegulated == null) { minDownRegulated = new FindTopLevelByRegulation(Regulation.DOWN).apply(Lists.reverse(this)); }/*from ww w . j av a 2s. co m*/ return minDownRegulated; }
From source file:net.hillsdon.reviki.wiki.plugin.PluginsImpl.java
public void handleChanges(final long upto, final List<ChangeInfo> chronological) { // We want to do the most recent first to prevent repeated work. try {/* w w w . j a v a 2 s.c o m*/ for (ChangeInfo change : Lists.reverse(chronological)) { if (change.getKind() == StoreKind.ATTACHMENT && change.getPage().equals(CONFIG_PLUGINS.getPath())) { PluginAtRevision plugin = _plugin.get(change.getName()); if (plugin == null || plugin.getRevision() < change.getRevision()) { updatePlugin(change); } } } } catch (Exception ex) { // If we propagate this then issues with plugins can disable a wiki. // Ideally we'd report this on ConfigPlugins only. LOG.error("Error encountered updating plugins", ex); } _lastSyncedRevision = upto; }
From source file:co.cask.cdap.explore.executor.AbstractQueryExecutorHttpHandler.java
protected List<QueryInfo> filterQueries(List<QueryInfo> queries, final long offset, final boolean isForward, final int limit) { // Reverse the list if the pagination is in the reverse from the offset until the max limit if (!isForward) { queries = Lists.reverse(queries); }//from w w w .j a v a 2 s . co m return FluentIterable.from(queries).filter(new Predicate<QueryInfo>() { @Override public boolean apply(@Nullable QueryInfo queryInfo) { if (isForward) { return queryInfo.getTimestamp() < offset; } else { return queryInfo.getTimestamp() > offset; } } }).limit(limit).toSortedImmutableList(new Comparator<QueryInfo>() { @Override public int compare(QueryInfo first, QueryInfo second) { //sort descending. return Longs.compare(second.getTimestamp(), first.getTimestamp()); } }); }
From source file:com.spotify.docker.client.auth.MultiRegistryAuthSupplier.java
@Override public RegistryConfigs authForBuild() throws DockerException { final Map<String, RegistryAuth> allConfigs = new HashMap<>(); // iterate through suppliers in reverse so that the earlier suppliers in the list // have precedence for (RegistryAuthSupplier supplier : Lists.reverse(suppliers)) { final RegistryConfigs configs = supplier.authForBuild(); if (configs != null && configs.configs() != null) { allConfigs.putAll(configs.configs()); }//from ww w . j a v a 2 s . co m } return RegistryConfigs.create(allConfigs); }
From source file:de.hzi.helmholtz.Modules.ModuleSimilarity.java
public double levenshteinSimilarity(Module query, List<Module> toCompare, double functionMatchWeight, double statusMatchWeight, double substrateMatchWeight) { int direction = 0; // tells if forward match was better or reverse List<String> qfunction = new ArrayList<String>(); List<String> qactivity = new ArrayList<String>(); List<Set<String>> qsubstrate = new ArrayList<Set<String>>(); for (Domain d : query.getDomains()) { qfunction.add(d.getDomainFunctionString()); qactivity.add(d.getStatus().toString()); qsubstrate.add(d.getSubstrates()); }//from w ww . j av a 2 s.com CosineSimilarity sim = new CosineSimilarity(); double finalscore = 0.0f; double functionscore = 0.0f; double statusScore = 0.0f; double substrateScore = 0.0f; // combine the list of genes into one in the forward direction .. and get levenshtein score double straightFunctionScore = 0.0f; List<String> tfunction = new ArrayList<String>(); List<String> tactivity = new ArrayList<String>(); List<Set<String>> tsubstrate = new ArrayList<Set<String>>(); for (Module g : toCompare) { Iterator<Domain> dIter = g.domainIterator(); while (dIter.hasNext()) { Domain d = dIter.next(); tfunction.add(d.getDomainFunctionString()); tactivity.add(d.getStatus().toString()); tsubstrate.add(d.getSubstrates()); } } straightFunctionScore = (double) sim.calculate(qfunction, tfunction); // straightFunctionScore = 1 - ((double) LevenshteinDistance.computeLevenshteinDistance(qfunction, tfunction) / (Math.max(qfunction.size(), tfunction.size()))); // combine the list of genes into one in the reverse direction .. and get levenshtein score Lists.reverse(toCompare); double reverseFunctionScore = 0.0f; List<String> rtfunction = new ArrayList<String>(); List<String> rtactivity = new ArrayList<String>(); List<Set<String>> rtsubstrate = new ArrayList<Set<String>>(); for (Module g : Lists.reverse(toCompare)) { Iterator<Domain> dIter = g.domainIterator(); while (dIter.hasNext()) { Domain d = dIter.next(); rtfunction.add(d.getDomainFunctionString()); rtactivity.add(d.getStatus().toString()); rtsubstrate.add(d.getSubstrates()); } } //reverseFunctionScore = 1 - ((double) LevenshteinDistance.computeLevenshteinDistance(qfunction, rtfunction) / (Math.max(qfunction.size(), rtfunction.size()))); reverseFunctionScore = (double) sim.calculate(qfunction, tfunction); if (straightFunctionScore >= reverseFunctionScore) { direction = 1; functionscore = straightFunctionScore; statusScore = getStatusComparisonScore(qactivity, tactivity); substrateScore = getSubstrateComparisonScore(qsubstrate, tsubstrate); } else { direction = -1; functionscore = reverseFunctionScore; statusScore = getStatusComparisonScore(qactivity, rtactivity); substrateScore = getSubstrateComparisonScore(qsubstrate, rtsubstrate); } finalscore = direction * Math.round((((2.9 * functionscore) + (0.05 * statusScore) + (0.05 * substrateScore)) / 3) * 100.0) / 100.0; /* if (functionMatchWeight == 0 || statusMatchWeight == 0 || substrateMatchWeight == 0) { finalscore = direction * Math.round((((2 * functionscore) + (0.5 * statusScore) + (0 * substrateScore)) / 2) * 100.0) / 100.0; } else { finalscore = direction * Math.round((((functionMatchWeight * functionscore) + (statusMatchWeight * statusScore) + (substrateMatchWeight * substrateScore)) / 2) * 100.0) / 100.0; }*/ return finalscore; }