List of usage examples for com.google.common.collect Collections2 transform
public static <F, T> Collection<T> transform(Collection<F> fromCollection, Function<? super F, T> function)
From source file:com.google.reviewit.app.QueryHandler.java
private void query() throws RestApiException { result.addAll(Collections2.transform(Collections2.filter(gerrit.api().changes().query(config.encodedQuery()) .withOption(ListChangesOption.ALL_FILES).withOption(ListChangesOption.CURRENT_COMMIT) .withOption(ListChangesOption.CURRENT_REVISION).withOption(ListChangesOption.DETAILED_ACCOUNTS) .withOption(ListChangesOption.DETAILED_LABELS).withLimit(LIMIT_QUERY).withStart(start).get(), new Predicate<ChangeInfo>() { @Override// www .j a va 2 s.co m public boolean apply(ChangeInfo changeInfo) { // filter out changes with no revisions return changeInfo.revisions != null; } }), new Function<ChangeInfo, Change>() { @Override public Change apply(ChangeInfo changeInfo) { return new Change(gerrit.api(), changeInfo); } })); start += LIMIT_QUERY; more = !result.isEmpty() && (result.getLast().info._moreChanges != null ? result.getLast().info._moreChanges : false); }
From source file:com.addthis.bundle.util.ConvertingSetView.java
@Override public boolean containsAll(Collection<?> c) { return source.containsAll(Collections2.transform(c, inputConverter::apply)); }
From source file:org.killbill.billing.jaxrs.json.TagDefinitionJson.java
public TagDefinitionJson(final TagDefinition tagDefinition, @Nullable final List<AuditLog> auditLogs) { this(tagDefinition.getId().toString(), tagDefinition.isControlTag(), tagDefinition.getName(), tagDefinition.getDescription(), ImmutableList.<String>copyOf(Collections2 .transform(tagDefinition.getApplicableObjectTypes(), new Function<ObjectType, String>() { @Override public String apply(@Nullable final ObjectType input) { if (input == null) { return ""; } else { return input.toString(); }/* www .ja v a 2s . c o m*/ } })), toAuditLogJson(auditLogs)); }
From source file:org.trnltk.util.MorphemeContainerFormatter.java
@SuppressWarnings("UnusedDeclaration") public static Collection<String> formatMorphemeContainers( final Collection<MorphemeContainer> morphemeContainers) { return Collections2.transform(morphemeContainers, new Function<MorphemeContainer, String>() { @Override// ww w . j a v a 2s . c o m public String apply(MorphemeContainer input) { return MorphemeContainerFormatter.formatMorphemeContainer(input); } }); }
From source file:org.sonar.server.measure.live.MeasureMatrix.java
MeasureMatrix(Collection<ComponentDto> components, Collection<MetricDto> metrics, List<LiveMeasureDto> dbMeasures) { for (MetricDto metric : metrics) { this.metricsByKeys.put(metric.getKey(), metric); this.metricsByIds.put(metric.getId(), metric); }//from ww w . j av a 2 s. c o m this.table = ArrayTable.create(Collections2.transform(components, ComponentDto::uuid), metricsByKeys.keySet()); for (LiveMeasureDto dbMeasure : dbMeasures) { table.put(dbMeasure.getComponentUuid(), metricsByIds.get(dbMeasure.getMetricId()).getKey(), new MeasureCell(dbMeasure, false)); } }
From source file:org.opendaylight.controller.netconf.cli.reader.impl.ContainerReader.java
@Override public List<Node<?>> readWithContext(final ContainerSchemaNode containerNode) throws IOException, ReadingException { console.formatLn("Submit child nodes for container: %s, %s", containerNode.getQName().getLocalName(), Collections2.transform(containerNode.getChildNodes(), new Function<DataSchemaNode, String>() { @Override//from www .ja v a2s . co m public String apply(final DataSchemaNode input) { return input.getQName().getLocalName(); } })); final CompositeNodeBuilder<ImmutableCompositeNode> compositeNodeBuilder = ImmutableCompositeNode.builder(); compositeNodeBuilder.setQName(containerNode.getQName()); final SeparatedNodes separatedNodes = SeparatedNodes.separateNodes(containerNode, getReadConfigNode()); for (final DataSchemaNode childNode : sortChildren(separatedNodes.getMandatoryNotKey())) { final List<Node<?>> redNodes = argumentHandlerRegistry .getGenericReader(getSchemaContext(), getReadConfigNode()).read(childNode); if (redNodes.isEmpty()) { console.formatLn("No data specified for mandatory element %s.", childNode.getQName().getLocalName()); return Collections.emptyList(); } else { compositeNodeBuilder.addAll(redNodes); } } for (final DataSchemaNode childNode : sortChildren(separatedNodes.getOthers())) { compositeNodeBuilder.addAll(argumentHandlerRegistry .getGenericReader(getSchemaContext(), getReadConfigNode()).read(childNode)); } return Collections.<Node<?>>singletonList(compositeNodeBuilder.toInstance()); }
From source file:com.ning.billing.invoice.api.invoice.DefaultInvoicePaymentApi.java
@Override public List<Invoice> getAllInvoicesByAccount(final UUID accountId, final TenantContext context) { return ImmutableList.<Invoice>copyOf(Collections2.transform( dao.getAllInvoicesByAccount(accountId, internalCallContextFactory.createInternalTenantContext(context)), new Function<InvoiceModelDao, Invoice>() { @Override/*from www .java 2s. co m*/ public Invoice apply(final InvoiceModelDao input) { return new DefaultInvoice(input); } })); }
From source file:eu.lp0.cursus.ui.table.RaceAttendeesDatabaseColumn.java
public void setRace(Race race) { if (race != null) { pilots.replaceAll(Collections2.transform( Ordering.from(new PilotRaceNumberComparator()).sortedCopy(race.getAttendees().keySet()), PilotWrapper.getFunction())); } else {//w w w .j a v a2 s . co m pilots.replaceAll(Collections.<PilotWrapper>emptySet()); } }
From source file:codecrafter47.bungeetablistplus.managers.PlayerManager.java
public List<IPlayer> getPlayers(Collection<String> filter, ProxiedPlayer who, boolean includeSuspectors) { List<IPlayer> list = new ArrayList<>(); Iterable<IPlayer> players = Iterables .concat(Collections2.transform(playerProviders, new Function<IPlayerProvider, Iterable<IPlayer>>() { @Override/*from www .j a va 2 s .c om*/ public Iterable<IPlayer> apply(IPlayerProvider iPlayerProvider) { return iPlayerProvider.getPlayers(); } })); for (IPlayer p : players) { boolean areGroupRules = false; boolean areServerRules = false; boolean fitGroupRules = false; boolean fitServerRules = false; String group = plugin.getPermissionManager().getMainGroup(p); for (String rule : filter) { if (rule.isEmpty()) { // ignore } else { Optional<ServerInfo> server = p.getServer(); if (rule.equalsIgnoreCase("currentserver")) { areServerRules = true; if (server.isPresent() && who.getServer() != null) { if (server.get().getName().equalsIgnoreCase(who.getServer().getInfo().getName())) { fitServerRules = true; } } } else if (isServer(rule)) { areServerRules = true; if (server.isPresent()) { if (server.get().getName().equalsIgnoreCase(rule)) { fitServerRules = true; } String[] s = rule.split("#"); if (s.length == 2) { if (server.get().getName().equalsIgnoreCase(s[0])) { String world = plugin.getBridge().getPlayerInformation(p, "world"); if (world != null) { if (world.equalsIgnoreCase(s[1])) { fitServerRules = true; } } } } } } else { areGroupRules = true; if (group != null) { if (group.equalsIgnoreCase(rule)) { fitGroupRules = true; } } } } } if (((!areServerRules) || fitServerRules) && ((!areGroupRules) || fitGroupRules) && !BungeeTabListPlus.isHidden(p, who) && (includeSuspectors || p.getGameMode() != 3)) { list.add(p); } } return list; }
From source file:org.jetbrains.jet.plugin.DirectiveBasedActionUtils.java
public static void checkAvailableActionsAreExpected(JetFile file, Collection<IntentionAction> availableActions) { List<String> validActions = Ordering.natural().sortedCopy(Lists .newArrayList(InTextDirectivesUtils.findLinesWithPrefixesRemoved(file.getText(), "// ACTION:"))); Collection<String> actualActions = Ordering.natural().sortedCopy(Lists .newArrayList(Collections2.transform(availableActions, new Function<IntentionAction, String>() { @Override/*from w w w . ja va 2s .c o m*/ public String apply(@Nullable IntentionAction input) { assert input != null; return input.getText(); } }))); UsefulTestCase.assertOrderedEquals( "Some unexpected actions available at current position: %s. Use // ACTION: directive", actualActions, validActions); }