List of usage examples for com.google.common.collect FluentIterable from
@Deprecated @CheckReturnValue public static <E> FluentIterable<E> from(FluentIterable<E> iterable)
From source file:com.google.gerrit.pgm.init.InitPlugins.java
private static List<PluginData> listPlugins(final SitePaths site, final boolean deleteTempPluginFile, PluginsDistribution pluginsDistribution) throws IOException { final List<PluginData> result = new ArrayList<>(); pluginsDistribution.foreach(new PluginsDistribution.Processor() { @Override//from ww w . j av a2 s . c o m public void process(String pluginName, InputStream in) throws IOException { Path tmpPlugin = JarPluginProvider.storeInTemp(pluginName, in, site); String pluginVersion = getVersion(tmpPlugin); if (deleteTempPluginFile) { Files.delete(tmpPlugin); } result.add(new PluginData(pluginName, pluginVersion, tmpPlugin)); } }); return FluentIterable.from(result).toSortedList(new Comparator<PluginData>() { @Override public int compare(PluginData a, PluginData b) { return a.name.compareTo(b.name); } }); }
From source file:org.eclipse.buildship.core.workspace.internal.LinkedResourcesUpdater.java
private LinkedResourcesUpdater(IProject project, List<OmniEclipseLinkedResource> linkedResources) { this.project = Preconditions.checkNotNull(project); this.linkedResources = FluentIterable.from(linkedResources).filter(new LinkedResourcesWithValidLocation()) .uniqueIndex(new Function<OmniEclipseLinkedResource, IFolder>() { @Override// w w w . jav a 2s . c o m public IFolder apply(OmniEclipseLinkedResource resource) { return LinkedResourcesUpdater.this.project.getFolder(resource.getLocation()); } }); }
From source file:io.crate.metadata.doc.PartitionedByMappingExtractor.java
public static Iterable<Tuple<ColumnIdent, DataType>> extractPartitionedByColumns( Collection<List<String>> partitionedByList) { return FluentIterable.from(partitionedByList).transform(EXTRACTOR_FUNCTION); }
From source file:org.onos.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement.java
protected AbstractDeclaredStatement(StmtContext<A, ?, ?> context) { rawArgument = context.rawStatementArgument(); argument = context.getStatementArgument(); source = context.getStatementSource(); definition = context.getPublicDefinition(); /*/*from w w w . java 2 s.c o m*/ * Collections.transform could not be used here, since it is lazily * transformed and retains pointer to original collection, which may * contains references to mutable context. * * FluentIterable.tranform().toList() - actually performs transformation * and creates immutable list from transformed results. */ substatements = FluentIterable.from(context.declaredSubstatements()) .transform(StmtContextUtils.buildDeclared()).toList(); }
From source file:org.apache.aurora.scheduler.storage.mem.MemAttributeStore.java
@Override public boolean saveHostAttributes(IHostAttributes attributes) { Preconditions.checkArgument(/* www. j a v a 2 s .c o m*/ FluentIterable.from(attributes.getAttributes()).allMatch(a -> !a.getValues().isEmpty())); Preconditions.checkArgument(attributes.isSetMode()); IHostAttributes previous = hostAttributes.put(attributes.getHost(), merge(attributes, Optional.ofNullable(hostAttributes.get(attributes.getHost())))); return !attributes.equals(previous); }
From source file:com.facebook.presto.operator.aggregation.MaxByAggregations.java
public static List<InternalAggregationFunction> getAggregations(TypeManager typeManager) { ImmutableList.Builder<InternalAggregationFunction> builder = ImmutableList.builder(); Set<Type> orderableTypes = FluentIterable.from(typeManager.getTypes()).filter(new Predicate<Type>() { @Override/*from www . j ava2 s. c om*/ public boolean apply(Type input) { return input.isOrderable(); } }).toSet(); for (Type keyType : orderableTypes) { for (Type valueType : typeManager.getTypes()) { builder.add(generateAggregation(valueType, keyType)); } } return builder.build(); }
From source file:com.b2international.commons.http.AcceptHeader.java
private static <T> List<T> parse(StringReader input, Function<String, T> converterFunction) throws IOException { final ImmutableList.Builder<AcceptHeader<T>> resultBuilder = ImmutableList.builder(); do {/*from w w w. j ava 2s . co m*/ String token = HttpParser.readToken(input); if (token == null) { HttpParser.skipUntil(input, 0, ','); continue; } if (token.length() == 0) { // No more data to read break; } // See if a quality has been provided double quality = 1; SkipResult lookForSemiColon = HttpParser.skipConstant(input, ";"); if (lookForSemiColon == SkipResult.FOUND) { quality = HttpParser.readWeight(input, ','); } if (quality > 0) { resultBuilder.add(new AcceptHeader<T>(converterFunction.apply(token), quality)); } } while (true); // Stable sort ensures that values with the same quality are not reordered final List<AcceptHeader<T>> sortedResults = Ordering.natural().reverse().sortedCopy(resultBuilder.build()); return FluentIterable.from(sortedResults).transform(new Function<AcceptHeader<T>, T>() { @Override public T apply(AcceptHeader<T> input) { return input.getValue(); } }).toList(); }
From source file:com.lyndir.omicron.api.Game.java
@Override public ImmutableList<? extends ILevel> getLevels() { return FluentIterable.from(thrift().getLevels()).transform(Level::new).toList(); }
From source file:org.pentaho.di.www.BaseCartePlugin.java
private static FluentIterable<String> fromEnumeration(Enumeration enumeration) { Iterable<?> list = Collections.list(enumeration); return FluentIterable.from(list).filter(String.class); }
From source file:org.raml.jaxrs.parser.model.JerseyJaxRsResource.java
@Override public List<JaxRsMethod> getMethods() { return FluentIterable.from(runtimeResource.getResourceMethods()) .transform(new Function<ResourceMethod, JaxRsMethod>() { @Nullable//ww w. ja v a 2 s. c o m @Override public JaxRsMethod apply(@Nullable ResourceMethod resourceMethod) { return ourMethodOf(resourceMethod, sourceParser); } }).toList(); }