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.hortonworks.streamline.streams.layout.storm.StreamsShellBoltFluxComponent.java
private List<String> getStreams() { Collection<String> streams = Collections2.transform(multiLangProcessor.getOutputStreams(), new Function<Stream, String>() { @Override// w ww . ja v a 2 s. c om public String apply(Stream input) { return input.getId(); } }); return ImmutableList.copyOf(streams); }
From source file:org.caleydo.view.domino.internal.undo.MergeGroupsCmd.java
@Override public ICmd run(Domino domino) { EDimension dim = node.getSingleGroupingDimension(); TypedGroupSet bak = node.getUnderlyingData(dim); List<TypedListGroup> d = new ArrayList<>(node.getData(dim).getGroups()); List<TypedSetGroup> r = new ArrayList<>(); List<Integer> indices = new ArrayList<>(); for (NodeGroup g : new ArrayList<>(groups)) { final TypedListGroup gd = g.getData(dim); r.add(gd.asSet());//from w w w. j a v a 2 s.c om int index = d.indexOf(gd); indices.add(index); d.remove(index); g.prepareRemoveal(); } TypedSetGroup mg = new TypedSetGroup(TypedSet.union(r), StringUtils.join(Collections2.transform(r, Labels.TO_LABEL), ", "), mixColors(r)); d.add(mg.asList()); TypedGroupList l = new TypedGroupList(d); node.setUnderlyingData(dim, l.asSet()); return new UndoMergeGroupsCmd(dim, bak); }
From source file:org.eclipse.viatra.query.patternlanguage.emf.EcoreGenmodelRegistry.java
/** * /* ww w.j ava 2 s.c o m*/ * @return a non-null, but possibly empty set of package instances * @since 1.0 */ public Collection<EPackage> getPackages() { return Collections2.transform(genpackageMap.values(), GenPackage::getEcorePackage); }
From source file:org.opendaylight.netconf.util.messages.NetconfMessageUtil.java
public static Collection<String> extractCapabilitiesFromHello(Document doc) throws NetconfDocumentedException { XmlElement responseElement = XmlElement.fromDomDocument(doc); // Extract child element <capabilities> from <hello> with or without(fallback) the same namespace Optional<XmlElement> capabilitiesElement = responseElement .getOnlyChildElementWithSameNamespaceOptionally(XmlNetconfConstants.CAPABILITIES) .or(responseElement.getOnlyChildElementOptionally(XmlNetconfConstants.CAPABILITIES)); List<XmlElement> caps = capabilitiesElement.get().getChildElements(XmlNetconfConstants.CAPABILITY); return Collections2.transform(caps, new Function<XmlElement, String>() { @Override//from w w w .j a v a 2 s . c o m public String apply(@Nonnull XmlElement input) { // Trim possible leading/tailing whitespace try { return input.getTextContent().trim(); } catch (DocumentedException e) { LOG.trace("Error fetching input text content", e); return null; } } }); }
From source file:com.b2international.commons.concurrent.equinox.ForkJoinUtils.java
public static void runInParallel(final Collection<Runnable> runnables) { final Collection<Job> jobs = Collections2.transform(runnables, new Function<Runnable, Job>() { @Override/*from w w w .j ava 2 s . c o m*/ public Job apply(final Runnable input) { return new ForkJoinJob(input); } }); runJobsInParallel(jobs); }
From source file:com.nesscomputing.migratory.loader.FileLoader.java
@Override public Collection<URI> loadFolder(final URI folderUri, final String searchPattern) { final Pattern pattern = (searchPattern == null) ? null : Pattern.compile(searchPattern); final File folderLocation = new File(folderUri); if (folderLocation.exists() && folderLocation.canRead()) { if (folderLocation.isDirectory()) { final File[] files = (pattern == null) ? folderLocation.listFiles() : folderLocation.listFiles(new PatternFilenameFilter(pattern)); return Collections2.transform(Arrays.asList(files), FILE_TO_URL); } else {//from ww w . j a v a 2 s . c o m throw new MigratoryException(Reason.INTERNAL, "%s is not a directory!", folderUri); } } else { throw new MigratoryException(Reason.INTERNAL, "Can not access %s!", folderUri); } }
From source file:com.hortonworks.streamline.streams.layout.component.impl.RulesProcessor.java
public void setRules(List<Rule> rules) { this.rules = rules; Set<String> streamIds = new HashSet<>( Collections2.transform(getOutputStreams(), new Function<Stream, String>() { @Override/*from w w w .j av a2s . c o m*/ public String apply(Stream input) { return input.getId(); } })); for (Rule rule : rules) { for (Action action : rule.getActions()) { for (String stream : action.getOutputStreams()) { if (!streamIds.contains(stream)) { String errorMsg = String.format( "Action [%s] stream [%s] does not exist in processor [%s]'s output streams [%s]", action, stream, getName(), streamIds); log.error(errorMsg); throw new IllegalArgumentException(errorMsg); } } } } }
From source file:com.ning.billing.jaxrs.json.AnalyticsSanityJson.java
public AnalyticsSanityJson(final Collection<UUID> checkEntitlement, final Collection<UUID> checkInvoice, final Collection<UUID> checkPayment, final Collection<UUID> checkTag, final Collection<UUID> checkConsistency) { this.checkEntitlement = ImmutableList .<String>copyOf(Collections2.transform(checkEntitlement, new Function<UUID, String>() { @Override// w w w .ja va2s . c o m public String apply(final UUID input) { return input.toString(); } })); this.checkInvoice = ImmutableList .<String>copyOf(Collections2.transform(checkInvoice, new Function<UUID, String>() { @Override public String apply(final UUID input) { return input.toString(); } })); this.checkPayment = ImmutableList .<String>copyOf(Collections2.transform(checkPayment, new Function<UUID, String>() { @Override public String apply(final UUID input) { return input.toString(); } })); this.checkTag = ImmutableList.<String>copyOf(Collections2.transform(checkTag, new Function<UUID, String>() { @Override public String apply(final UUID input) { return input.toString(); } })); this.checkConsistency = ImmutableList .<String>copyOf(Collections2.transform(checkConsistency, new Function<UUID, String>() { @Override public String apply(final UUID input) { return input.toString(); } })); }
From source file:org.opendaylight.controller.cluster.datastore.FrontendMetadata.java
@Override FrontendShardDataTreeSnapshotMetadata toSnapshot() { return new FrontendShardDataTreeSnapshotMetadata( Collections2.transform(clients.values(), FrontendClientMetadataBuilder::build)); }
From source file:com.ace.commons.mybatis.type.StringToSetTypeHander.java
/** * ?string,/*from w w w. ja va2s .c o m*/ * @param result * @param regex ,',' * @return */ private Set<Long> stringToSet(String result, String regex) { if (StringUtils.isNotBlank(result)) { //?split ',' ??list List<String> list = Arrays.asList(result.split(StringUtils.isBlank(regex) ? "," : regex)); if (list == null || list.size() <= 0) { return null; } return Sets.newHashSet(Collections2.transform(list, new Function<String, Long>() { @Override public Long apply(String itme) { return Long.parseLong(itme); } })); } return null; }