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.cloudera.gertrude.server.condition.IntHeaderCondition.java
@Override protected Set<Integer> parseArgs(List<String> args) { if (args.size() < 2) { throw new IllegalStateException("IntHeaderCondition function must have at least two arguments"); }/* w w w.j a v a2s .co m*/ // The first argument is the attribute to look for in the header this.header = args.get(0); // the second return ImmutableSet.copyOf(Lists.transform(args.subList(1, args.size()), new Function<String, Integer>() { @Override public Integer apply(String input) { return Integer.valueOf(input); } })); }
From source file:org.magnum.mcc.building.guessers.UserLocationsFeedbackGuesser.java
@Override public void guess(final LocationGuesser guesser, Measurements ms) { for (Measurement m : ms.getMeasurements()) { if (TYPE.equals(m.getType())) { String[] values = m.getValues(); if (values != null && values.length > 0) { List<FloorplanLocation> possible = Lists.transform(Arrays.asList(values), new Function<String, FloorplanLocation>() { public FloorplanLocation apply(String id) { return guesser.getFloorplan().locationById(id); }// w w w . j a v a 2 s . c om }); guesser.narrowLocations(new HashSet<FloorplanLocation>(possible)); } } } }
From source file:org.apache.druid.query.UnionQueryRunner.java
@Override public Sequence<T> run(final QueryPlus<T> queryPlus, final Map<String, Object> responseContext) { Query<T> query = queryPlus.getQuery(); DataSource dataSource = query.getDataSource(); if (dataSource instanceof UnionDataSource) { return new MergeSequence<>(query.getResultOrdering(), Sequences.simple(Lists.transform(((UnionDataSource) dataSource).getDataSources(), new Function<DataSource, Sequence<T>>() { @Override public Sequence<T> apply(DataSource singleSource) { return baseRunner.run(queryPlus.withQuery(query.withDataSource(singleSource)), responseContext); }// w w w. j a va 2 s .com }))); } else { return baseRunner.run(queryPlus, responseContext); } }
From source file:org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort.java
/** * Topological sort of module dependency graph. * * @param modules YANG modules// w w w . j av a2 s . com * @return Sorted list of Modules. Modules can be further processed in * returned order. */ public static List<Module> sort(final Module... modules) { final List<TopologicalSort.Node> sorted = sortInternal(Arrays.asList(modules)); // Cast to Module from Node and return return Lists.transform(sorted, TOPOLOGY_FUNCTION); }
From source file:ninja.leaping.permissionsex.backend.file.SchemaMigrations.java
static ConfigurationTransformation threeToFour() { return ConfigurationTransformation.chain(tBuilder() .addAction(new Object[] { "worlds", WILDCARD_OBJECT, "inheritance" }, (inputPath, valueAtPath) -> { try { valueAtPath.setValue(Lists.transform(valueAtPath.getList(TypeToken.of(String.class)), input -> "world:" + input)); } catch (ObjectMappingException e) { throw new RuntimeException(e); }//from w w w . ja va 2s . co m return new Object[] { "context-inheritance", "world:" + inputPath.get(1) }; }).build(), tBuilder().addAction(new Object[] { "worlds" }, (inputPath, valueAtPath) -> { valueAtPath.setValue(null); return null; }).build()); }
From source file:br.com.caelum.vraptor.interceptor.DefaultInterceptorRegistry.java
public Interceptor[] interceptorsFor(ResourceMethod method, Container container) { List<Interceptor> list = Lists.transform(interceptors, Functions.<Interceptor>instanceWith(container)); Collection<Interceptor> filtered = Collections2.filter(list, Filters.accepts(method)); return filtered.toArray(new Interceptor[0]); }
From source file:org.lazulite.boot.autoconfigure.osaam.shiro.sys.group.service.GroupService.java
public Set<Map<String, Object>> findIdAndNames(Pageable pageable, String groupName) { return Sets.newHashSet(Lists.transform(findAll(), new Function<Group, Map<String, Object>>() { @Override/*from w w w . j a v a2s.co m*/ public Map<String, Object> apply(Group input) { Map<String, Object> data = Maps.newHashMap(); data.put("label", input.getName()); data.put("value", input.getId()); return data; } })); }
From source file:org.jenkinsci.plugins.runselector.RunFilter.java
/** * @return all descriptors of {@link RunFilter} without {@link NoRunFilter} *//* ww w .j a v a 2 s .co m*/ public static List<RunFilterDescriptor> all() { Jenkins j = Jenkins.getInstance(); if (j == null) { return Collections.emptyList(); } return Lists.transform(j.getDescriptorList(RunFilter.class), new Function<Descriptor<?>, RunFilterDescriptor>() { @Override public RunFilterDescriptor apply(Descriptor<?> arg0) { return (RunFilterDescriptor) arg0; } }); }
From source file:com.b2international.snowowl.datastore.ClientProtocolFactoryRegistry.java
public List<ClientProtocolFactory> getRegisteredClientProtocolFactories() { IConfigurationElement[] configurationElements = Platform.getExtensionRegistry() .getConfigurationElementsFor(EXTENSION_POINT_ID); return Lists.transform(Arrays.asList(configurationElements), new Function<IConfigurationElement, ClientProtocolFactory>() { @Override//from w w w . j av a2 s . co m public ClientProtocolFactory apply(IConfigurationElement input) { try { return (ClientProtocolFactory) input.createExecutableExtension(CLASS_ATTRIBUTE); } catch (final CoreException e) { throw new RuntimeException( "Error while creating executable extension from the passed in configuration element: " + input, e); } } }); }
From source file:org.elasticsearch.discovery.gce.mock.GceComputeServiceZeroNodeMock.java
@Override public Collection<Instance> instances() { logger.debug("get instances for zoneList [{}]", zoneList); List<List<Instance>> instanceListByZone = Lists.transform(zoneList, new Function<String, List<Instance>>() { @Override/*from w w w . j a v a 2s . c om*/ public List<Instance> apply(String zoneId) { // If we return null here we will get a trace as explained in issue 43 return new ArrayList(); } }); //Collapse instances from all zones into one neat list List<Instance> instanceList = Lists.newArrayList(Iterables.concat(instanceListByZone)); if (instanceList.size() == 0) { logger.warn("disabling GCE discovery. Can not get list of nodes"); } return instanceList; }