List of usage examples for com.google.common.collect Lists transform
@CheckReturnValue public static <F, T> List<T> transform(List<F> fromList, Function<? super F, ? extends T> function)
From source file:com.eharmony.matching.seeking.executor.solr.SolrResultsTransformer.java
public <T> List<T> transform(SolrDocumentList results, final Class<T> returnType) { if (isValueType(returnType)) { return Lists.transform(results, new Function<SolrDocument, T>() { @Override/*from ww w . j ava 2s .co m*/ public T apply(SolrDocument document) { Iterator<Object> iterator = document.values().iterator(); return iterator.hasNext() ? returnType.cast(iterator.next()) : null; } }); } else { return binder.getBeans(returnType, results); } }
From source file:controllers.modules.CorpusModule.java
public static List<PersistentDocumentStoreModel> getCorpora() { PersistentDocumentStoreController docStoreController = new PersistentDocumentStoreController(); return Lists.transform(docStoreController.getAllUuids(em(), getUsername(), DocumentCorpus.class), new Function<String, PersistentDocumentStoreModel>() { @Override//from ww w .j a v a 2 s . c o m @Nullable public PersistentDocumentStoreModel apply(@Nullable String input) { PersistentDocumentStore store = fetchResource(UuidUtils.create(input), PersistentDocumentStore.class); PersistentDocumentStoreModel storeVM = (PersistentDocumentStoreModel) createViewModel( store); storeVM.populateSize(em(), store); return storeVM; } }); }
From source file:models.Feed.java
static List<Feed> load(List<ObjectId> feedIds) { List<Feed> feeds = null; try {/*from w w w. j a v a2 s .co m*/ DBObject query = new BasicDBObject("_id", new BasicDBObject().append("$in", feedIds.toArray(new ObjectId[feedIds.size()]))); DBCursor iobj = MongoDB.getDB().getCollection(MongoDB.CFeed).find(query); if (iobj != null) feeds = Lists.transform(iobj.toArray(), MongoDB.getSelf().toFeed()); //? .toFeedWithContent() } catch (Exception ex) { Logger.info("load feeds::"); ex.printStackTrace(); Logger.info(ex.toString()); } return feeds; }
From source file:com.facebook.presto.operator.aggregation.AbstractTestAggregationFunction.java
protected final InternalAggregationFunction getFunction() { Signature signature = functionRegistry.resolveFunction(QualifiedName.of(getFunctionName()), Lists.transform(getFunctionParameterTypes(), TypeSignature::parseTypeSignature), isApproximate()); return functionRegistry.getAggregateFunctionImplementation(signature); }
From source file:org.jpmml.evaluator.CsvUtil.java
static public List<String> parseLine(String line) { List<String> cells = Arrays.asList(line.split(",")); Function<String, String> function = new Function<String, String>() { @Override//from www.j a va 2 s . c om public String apply(String cell) { if ("NA".equals(cell) || "N/A".equals(cell)) { return null; } return cell; } }; return Lists.transform(cells, function); }
From source file:io.crate.executor.transport.distributed.MultiBucketBuilder.java
public List<Bucket> build() { return Lists.transform(bucketBuilders, StreamBucket.Builder.BUILD_FUNCTION); }
From source file:org.cloudifysource.restDoclet.docElements.DocRequestMappingAnnotation.java
public List<String> getMethod() { return Lists.transform(getStringListValue(RestDocConstants.REQUEST_MAPPING_METHOD).or(EMPTY_LIST), SIMPLE_NAME_FUN); }
From source file:org.apereo.portal.io.xml.dlm.FragmentDefinitionDataFunction.java
@Override public Iterable<? extends IPortalData> apply(IPortalDataType input) { final List<FragmentDefinition> fragmentDefinitions = this.fragmentDefinitionDao.getAllFragments(); final List<IPortalData> portalData = Lists.transform(fragmentDefinitions, new Function<FragmentDefinition, IPortalData>() { @Override// w w w .j a v a 2s . co m public IPortalData apply(FragmentDefinition fragmentDefinition) { return new SimpleStringPortalData(fragmentDefinition.getName(), null, fragmentDefinition.getDescription()); } }); return portalData; }
From source file:uk.co.danielrendall.metaphor.records.MATRIX.java
public MATRIX(Options options, Nudge nudge, int vAlign, int hJust, int vJust, int rows, int cols, List<Integer> rowPartition, List<Integer> columnPartition, List<List<Record>> rowList) { this.options = options; this.nudge = nudge; this.vAlign = vAlign; this.hJust = hJust; this.vJust = vJust; this.rows = rows; this.cols = cols; this.rowPartition = rowPartition; this.columnPartition = columnPartition; List<List<Record>> newRowList = Lists .newArrayList(Lists.transform(rowList, new Function<List<Record>, List<Record>>() { public List<Record> apply(@Nullable List<Record> input) { return ImmutableList.copyOf(input); }/*from w w w . j a va 2 s . co m*/ })); this.rowList = ImmutableList.copyOf(newRowList); }
From source file:org.ow2.sirocco.cloudmanager.api.openstack.server.resources.nova.extensions.functions.SecurityGroupToSecurityGroup.java
@Override public org.ow2.sirocco.cloudmanager.api.openstack.nova.extensions.securitygroups.model.SecurityGroup apply( SecurityGroup input) {/*from w w w . j a va 2s.c o m*/ org.ow2.sirocco.cloudmanager.api.openstack.nova.extensions.securitygroups.model.SecurityGroup result = new org.ow2.sirocco.cloudmanager.api.openstack.nova.extensions.securitygroups.model.SecurityGroup(); result.setName(input.getName()); if (input.getTenant() != null) { result.setTenantId(input.getTenant().getUuid()); } result.setDescription(input.getDescription()); result.setId(input.getUuid()); if (input.getRules() != null) { result.setRules(Lists.transform(input.getRules(), new SecurityGroupRuleToRule())); } return result; }