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:eu.esdihumboldt.hale.common.instance.extension.filter.FilterDefinitionManager.java
/** * @see AbstractObjectFactory#getDefinitions() *///from w w w .j a v a2 s .c om @Override protected List<FilterDefinition<?>> getDefinitions() { return Lists.transform(extension.getFactories(), new Function<FilterDefinitionFactory, FilterDefinition<?>>() { @Override public FilterDefinition<?> apply(FilterDefinitionFactory input) { try { return input.createExtensionObject(); } catch (Exception e) { throw new IllegalStateException("Could not create filter definition", e); } } }); }
From source file:org.apache.jackrabbit.oak.spi.security.authentication.token.CompositeTokenConfiguration.java
@Nonnull @Override// w ww .j a v a 2s .c o m public TokenProvider getTokenProvider(final Root root) { List<TokenProvider> providers = Lists.transform(getConfigurations(), new Function<TokenConfiguration, TokenProvider>() { @Override public TokenProvider apply(TokenConfiguration tokenConfiguration) { return tokenConfiguration.getTokenProvider(root); } }); return CompositeTokenProvider.newInstance(providers); }
From source file:com.google.devtools.build.android.aapt2.StaticLibrary.java
public static Collection<String> toPathStrings(List<StaticLibrary> libraries) { return Lists.transform(libraries, StaticLibrary::asLibraryPathString); }
From source file:com.onboard.domain.transform.TodolistTransform.java
public static TodolistDTO todolistToTodolistWithDicardTodosAndCommentsAndTodos(Todolist todolist) { TodolistDTO todolistDTO = new TodolistDTO(); BeanUtils.copyProperties(todolist, todolistDTO); if (todolist.getTodos() != null) { todolistDTO.setTodos(Lists.transform(todolist.getTodos(), TodoTransform.TODO_DTO_FUNCTION)); }/* w ww. ja v a 2 s . c o m*/ if (todolist.getDicardTodos() != null) { todolistDTO.setDicardTodos(Lists.transform(todolist.getDicardTodos(), TodoTransform.TODO_DTO_FUNCTION)); } if (todolist.getComments() != null) { todolistDTO .setComments(Lists.transform(todolist.getComments(), CommentTransform.COMMENT_TO_DTO_FUNCTION)); } if (todolist.getSubscribers() != null) { todolistDTO.setSubscribers( Lists.transform(todolist.getSubscribers(), UserTransform.USER_TO_USERDTO_FUNCTION)); } return todolistDTO; }
From source file:net.seedboxer.web.service.ContentsService.java
public List<ContentInfo> getUserContents(User user) { List<Content> allContents = contentManager.getAllContents(user); return Lists.transform(allContents, new Function<Content, ContentInfo>() { @Override//from www. ja v a2 s. co m @Nullable public ContentInfo apply(@Nullable Content content) { return createUserContentType(content); } }); }
From source file:io.v.rx.syncbase.UserCloudSyncgroup.java
private Observable<Void> ensureSyncgroup(final String sgHost, final String sgName, final SyncgroupSpec spec) { // We need app/db/table to sync even on the cloud. // https://github.com/vanadium/issues/issues/857 // Use idempotent APIs to allow failure recovery and avoid race conditions. Most of the // time, we'll just short-circuit and join the syncgroup from the get-go. final RxDb remoteDb = RxSyncbase.fromSyncbaseAt(mParams.getVContext(), sgHost) .rxApp(mParams.getDb().getRxApp().getName()).rxDb(mParams.getDb().getName()); final List<String> tableNames = Lists.transform(mParams.getPrefixes(), TableRow::getTableName); return SgHostUtil.ensureSyncgroupHierarchies(remoteDb, tableNames) // Syncgroup create is implicitly deferred via flatMap from a real observable. // Create this syncgroup on the remote Syncbase to auto-join that remote and sync // data to it. Otherwise, we won't actually write anything to the cloud syncbase. .switchMap(db -> toObservable( db.getSyncgroup(sgName).create(mParams.getVContext(), spec, mParams.getMemberInfo())) .doOnCompleted(() -> log.info("Created syncgroup " + sgName + " remotely")) .onErrorResumeNext(t -> t instanceof ExistException ? Observable.just(null) : Observable.error(t))); }
From source file:com.textocat.textokit.commons.cas.AITOverlapIndex.java
@Override public Set<A> getOverlapping(int begin, int end) { Set<A> result = Sets.newLinkedHashSet(); List<OffsetsWithValue<A>> resultList = tree.getOverlapping(begin, end); result.addAll(Lists.transform(resultList, new Function<OffsetsWithValue<A>, A>() { @Override/* w w w .ja va 2s .com*/ public A apply(OffsetsWithValue<A> input) { return input.getValue(); } })); return result; }
From source file:com.blacklocus.jres.response.search.JresSearchReply.java
/** * Shortcut to {@link Hit#getSourceAsType(Class)} *///from w w w.j a v a 2 s.c o m public <T> List<T> getHitsAsType(final Class<T> klass) { return Lists.transform(getHits().getHits(), new Function<Hit, T>() { @Override public T apply(Hit hit) { return hit.getSourceAsType(klass); } }); }
From source file:org.sosy_lab.cpachecker.util.predicates.interfaces.basicimpl.AbstractQuantifiedFormulaManager.java
@Override public BooleanFormula exists(List<Formula> pVariables, BooleanFormula pBody) { return wrap(exists(Lists.transform(pVariables, extractor), extractInfo(pBody))); }
From source file:org.apache.helix.util.RebalanceUtil.java
public static Map<String, Object> buildInternalIdealState(IdealState state) { // Try parse the partition number from name DB_n. If not, sort the partitions and // assign id/*from w ww . j a va2 s . co m*/ Map<String, Integer> partitionIndex = new HashMap<String, Integer>(); Map<String, String> reversePartitionIndex = new HashMap<String, String>(); boolean indexInPartitionName = true; for (PartitionId partitionId : state.getPartitionIdSet()) { String partitionName = partitionId.stringify(); int lastPos = partitionName.lastIndexOf("_"); if (lastPos < 0) { indexInPartitionName = false; break; } try { String idStr = partitionName.substring(lastPos + 1); int partition = Integer.parseInt(idStr); partitionIndex.put(partitionName, partition); reversePartitionIndex.put(state.getResourceId().stringify() + "_" + partition, partitionName); } catch (Exception e) { indexInPartitionName = false; partitionIndex.clear(); reversePartitionIndex.clear(); break; } } if (indexInPartitionName == false) { List<String> partitions = new ArrayList<String>(); partitions.addAll( Lists.transform(Lists.newArrayList(state.getPartitionIdSet()), Functions.toStringFunction())); Collections.sort(partitions); for (int i = 0; i < partitions.size(); i++) { partitionIndex.put(partitions.get(i), i); reversePartitionIndex.put(state.getResourceId().stringify() + "_" + i, partitions.get(i)); } } Map<String, List<Integer>> nodeMasterAssignmentMap = new TreeMap<String, List<Integer>>(); Map<String, Map<String, List<Integer>>> combinedNodeSlaveAssignmentMap = new TreeMap<String, Map<String, List<Integer>>>(); for (PartitionId partition : state.getPartitionIdSet()) { List<String> instances = state.getRecord().getListField(partition.stringify()); String master = instances.get(0); if (!nodeMasterAssignmentMap.containsKey(master)) { nodeMasterAssignmentMap.put(master, new ArrayList<Integer>()); } if (!combinedNodeSlaveAssignmentMap.containsKey(master)) { combinedNodeSlaveAssignmentMap.put(master, new TreeMap<String, List<Integer>>()); } nodeMasterAssignmentMap.get(master).add(partitionIndex.get(partition)); for (int i = 1; i < instances.size(); i++) { String instance = instances.get(i); Map<String, List<Integer>> slaveMap = combinedNodeSlaveAssignmentMap.get(master); if (!slaveMap.containsKey(instance)) { slaveMap.put(instance, new ArrayList<Integer>()); } slaveMap.get(instance).add(partitionIndex.get(partition)); } } Map<String, Object> result = new TreeMap<String, Object>(); result.put("PrimaryAssignmentMap", nodeMasterAssignmentMap); result.put("SecondaryAssignmentMap", combinedNodeSlaveAssignmentMap); result.put("replicas", Integer.parseInt(state.getReplicas())); result.put("partitions", new Integer(state.getRecord().getListFields().size())); result.put("reversePartitionIndex", reversePartitionIndex); return result; }