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:org.opendaylight.netconf.sal.restconf.impl.FakeRestconfModule.java
/** * Instantiate a new fake module// w ww . j a va 2 s . c o m * * @param neededModules needed import statements * @param child fake child container */ public FakeRestconfModule(final Collection<Module> neededModules, final ContainerSchemaNode child) { this.children = ImmutableList.of(child); this.imports = ImmutableSet.copyOf(Collections2.transform(neededModules, FakeModuleImport::new)); }
From source file:nl.surfnet.sab.SabClientMock.java
@Override public Collection<SabPerson> getPersonsInRoleForOrganization(String organisationAbbreviation, String role) { List<SabPerson> result = new ArrayList<>(); for (SabPerson sabPerson : sabPersons) { Collection<String> roleNames = Collections2.transform(sabPerson.getRoles(), new Function<SabRole, String>() { @Override/*from ww w . j a v a 2 s .co m*/ public String apply(SabRole input) { return input.roleName; } }); if (roleNames.contains(role)) { result.add(sabPerson); } } return result; }
From source file:com.vmware.thinapp.workpool.web.controllers.VmImagesController.java
@RequestMapping(method = RequestMethod.GET) @ResponseBody/*from ww w .ja v a 2 s . c o m*/ public VmImage[] list() { // Can't return Collection<VmImage> otherwise @class member doesn't get set. Collection<VmImage> vmImages = Collections2.transform(vmImageManager.list(), new Function<VmImageInstance, VmImage>() { @Override public VmImage apply(VmImageInstance vmImage) { return VmImageConverter.toDto(vmImage); } }); return vmImages.toArray(new VmImage[vmImages.size()]); }
From source file:uk.ac.ebi.atlas.solr.query.builders.SolrQueryBuilder.java
protected Collection<String> transformToConditions(final String filedName, Set<String> values) { return Collections2.transform(values, new Function<String, String>() { @Override//from w ww . jav a 2 s . c o m public String apply(String bioEntityType) { return filedName.concat(":\"").concat(bioEntityType).concat("\""); } }); }
From source file:org.mayocat.shop.shipping.DefaultShippingService.java
@Override public String getDestinationNames(List<String> destinationCodes) { if (destinationCodes == null) { // Garbage in, garbage out return null; }//from ww w . jav a2 s .com Collection<String> result = Collections2.transform(destinationCodes, new Function<String, String>() { @Override public String apply(final String code) { return getDestinationName(code); } }); result = (Collections2.filter(result, Predicates.notNull())); Joiner joiner = Joiner.on(", "); return joiner.join(result); }
From source file:com.google.devtools.build.android.DataSourceTable.java
private void writeSourceInfo(NavigableMap<DataKey, DataValue> map, OutputStream outStream) throws IOException { int sourceNumber = 0; LinkedList<DataSource> sourceQueue = new LinkedList<>( Collections2.transform(map.values(), VALUE_TO_SOURCE)); while (!sourceQueue.isEmpty()) { DataSource source = sourceQueue.pop(); if (!sourceTable.containsKey(source)) { sourceTable.put(source, sourceNumber); ++sourceNumber;/*w w w .j av a 2 s .c o m*/ sourceQueue.addAll(source.overrides()); } } for (DataSource dataSource : sourceTable.keySet()) { ProtoSource.newBuilder().setFilename(dataSource.getPath().toString()) .addAllOverwritten(sourcesToIds(dataSource.overrides())).build().writeDelimitedTo(outStream); } }
From source file:retrievers.flickr.PhotoQueryForGroup.java
public Collection<Place> getPlaces() throws IOException { Document doc = Jsoup.connect(makeRequestUrl()).get(); Elements photoElements = doc.select("photo"); // returns elements mapped onto places return Collections2.transform(photoElements, photoElementToPlaceMapping); }
From source file:com.palantir.atlasdb.shell.AtlasShellNamedColumnTableModel.java
public AtlasShellNamedColumnTableModel(final TableMetadata tableMetadata, List<String> columns, List<RowResult<byte[]>> rows) { Preconditions.checkArgument(!tableMetadata.getColumns().hasDynamicColumns()); this.tableMetadata = tableMetadata; this.rows = rows; if (columns == null || columns.isEmpty()) { this.columns = ImmutableList.copyOf(tableMetadata.getColumns().getNamedColumns()); } else {//from w ww . jav a 2 s . co m this.columns = ImmutableList .copyOf(Collections2.transform(columns, new Function<String, NamedColumnDescription>() { @Override public NamedColumnDescription apply(String columnName) { for (NamedColumnDescription nc : tableMetadata.getColumns().getNamedColumns()) { if (nc.getLongName().equals(columnName) || nc.getShortName().equals(columnName)) { return nc; } } throw new IllegalArgumentException("Unknown column " + columnName); } })); } }
From source file:org.caleydo.view.domino.internal.toolbar.ToolBar.java
/** * @param selection//www. j ava 2 s . c om */ private void updateLabel(Set<NodeGroup> selection) { label.setRenderer( GLRenderers.drawText(StringUtils.join(Collections2.transform(selection, Labels.TO_LABEL), ", "), VAlign.LEFT, new GLPadding(2, 4))); }
From source file:org.opennms.newts.rest.Transform.java
/** * Convert samples to {@link SampleDTO}s. * * @param samples/*from w w w . j av a2s . c om*/ * samples to convert. * @return converted samples. */ static Collection<Collection<SampleDTO>> sampleDTOs(Results<Sample> samples) { return Lists.newArrayList( Iterables.transform(samples, new Function<Results.Row<Sample>, Collection<SampleDTO>>() { @Override public Collection<SampleDTO> apply(Row<Sample> input) { return Collections2.transform(input.getElements(), new Function<Sample, SampleDTO>() { @Override public SampleDTO apply(Sample input) { return new SampleDTO(input.getTimestamp().asMillis(), new ResourceDTO(input.getResource().getId(), unwrapMap(input.getResource().getAttributes())), input.getName(), input.getType(), input.getValue(), input.getAttributes(), input.getContext().getId()); } }); } })); }