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.facebook.buck.cxx.PrefixMapDebugPathSanitizer.java
public PrefixMapDebugPathSanitizer(int pathSize, char separator, Path fakeCompilationDirectory, ImmutableBiMap<Path, Path> other, Path realCompilationDirectory, CxxToolProvider.Type cxxType) { super(separator, pathSize, fakeCompilationDirectory); this.isGcc = cxxType == CxxToolProvider.Type.GCC; this.compilationDir = realCompilationDirectory; ImmutableBiMap.Builder<Path, Path> pathsBuilder = ImmutableBiMap.builder(); // As these replacements are processed one at a time, if one is a prefix (or actually is just // contained in) another, it must be processed after that other one. To ensure that we can // process them in the correct order, they are inserted into allPaths in order of length // (longest first). Then, if they are processed in the order in allPaths, prefixes will be // handled correctly. pathsBuilder.putAll(FluentIterable.from(other.entrySet()).toSortedList( (left, right) -> right.getKey().toString().length() - left.getKey().toString().length())); // We assume that nothing in other is a prefix of realCompilationDirectory (though the reverse // is fine).//from w ww. j a v a 2 s .c o m pathsBuilder.put(realCompilationDirectory, fakeCompilationDirectory); for (Path p : other.keySet()) { Assertions.assertCondition(!realCompilationDirectory.toString().contains(p.toString())); } this.allPaths = pathsBuilder.build(); }
From source file:org.jclouds.azurecompute.arm.compute.functions.VMHardwareToHardware.java
@Override public Hardware apply(VMHardware from) { final HardwareBuilder builder = new HardwareBuilder().name(from.name()).providerId(from.name()) .id(fromLocationAndName(from.location(), from.name()).slashEncode()) .processors(ImmutableList.of(new Processor(from.numberOfCores(), 2))).ram(from.memoryInMB()) .location(FluentIterable.from(locations.get()) .firstMatch(LocationPredicates.idEquals(from.location())).get()); // No id or providerId from Azure if (from.resourceDiskSizeInMB() != null) { builder.volume(new VolumeBuilder().size(Float.valueOf(from.resourceDiskSizeInMB())) .type(Volume.Type.LOCAL).build()); }//from w w w .java 2 s . c o m if (from.osDiskSizeInMB() != null) { builder.volume( new VolumeBuilder().size(Float.valueOf(from.osDiskSizeInMB())).type(Volume.Type.LOCAL).build()); } ImmutableMap.Builder<String, String> metadata = ImmutableMap.builder(); metadata.put("maxDataDiskCount", String.valueOf(from.maxDataDiskCount())); builder.userMetadata(metadata.build()); return builder.build(); }
From source file:com.eucalyptus.util.CollectionUtils.java
/** * Create a fluent iterable for the given iterable. * * @param iterable The possibly null iterable * @param <T> The iterable type//from w w w . j a v a 2 s .c o m * @return the FluentIterable */ @Nonnull public static <T> FluentIterable<T> fluent(@Nullable final Iterable<T> iterable) { return FluentIterable.from(iterable == null ? Collections.<T>emptyList() : iterable); }
From source file:com.cognifide.aet.cleaner.processors.FetchAllProjectSuitesProcessor.java
@Override @SuppressWarnings("unchecked") public void process(Exchange exchange) throws Exception { final CleanerContext cleanerContext = exchange.getIn().getHeader(CleanerContext.KEY_NAME, CleanerContext.class); final DBKey dbKey = exchange.getIn().getBody(DBKey.class); LOGGER.info("Querying for unused data in {}", dbKey); final List<Suite> allProjectSuites = metadataDAO.listSuites(dbKey); final ImmutableListMultimap<String, Suite> groupedSuites = FluentIterable.from(allProjectSuites) .index(new Function<Suite, String>() { @Override//from www. j a va 2 s.c o m public String apply(Suite suite) { return suite.getName(); } }); LOGGER.info("Found {} distinct suites in {}", groupedSuites.keySet().size(), dbKey); final ImmutableList<AllSuiteVersionsMessageBody> body = FluentIterable .from(groupedSuites.asMap().entrySet()) .transform(new Function<Map.Entry<String, Collection<Suite>>, AllSuiteVersionsMessageBody>() { @Override public AllSuiteVersionsMessageBody apply(Map.Entry<String, Collection<Suite>> input) { return new AllSuiteVersionsMessageBody(input.getKey(), dbKey, input.getValue()); } }).toList(); exchange.getOut().setBody(body); exchange.getOut().setHeader(CleanerContext.KEY_NAME, cleanerContext); }
From source file:org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver.java
public ValueMetaResolver(RowMetaInterface rowMeta) { fieldNameValueMetaMap = FluentIterable.from(rowMeta.getValueMetaList()).transform(setDefaultConversionMask) .uniqueIndex(new Function<ValueMetaInterface, String>() { @Override//from w ww . j a v a2 s . com public String apply(ValueMetaInterface valueMetaInterface) { return valueMetaInterface.getName(); } }); }
From source file:com.facebook.buck.features.d.DLibrary.java
@Override public Iterable<NativeLinkable> getNativeLinkableExportedDeps(BuildRuleResolver ruleResolver) { return FluentIterable.from(getDeclaredDeps()).filter(NativeLinkable.class); }
From source file:org.mayocat.accounts.store.memory.MemoryUserStore.java
public User findUserByEmailOrUserName(String userNameOrEmail) { return FluentIterable.from(findAll(0, 0)).filter(withUserNameOrEmail(userNameOrEmail)).first().orNull(); }
From source file:com.facebook.buck.rules.SourcePaths.java
public static ImmutableSortedSet<SourcePath> toSourcePathsSortedByNaturalOrder(@Nullable Iterable<Path> paths) { if (paths == null) { return ImmutableSortedSet.of(); }// w w w . ja v a 2s .com return FluentIterable.from(paths).transform(TO_SOURCE_PATH).toSortedSet(Ordering.natural()); }
From source file:jetbrains.jetpad.completion.CompletionSupplier.java
public final boolean isAsyncEmpty(CompletionParameters cp) { Async<? extends Iterable<CompletionItem>> async = getAsync(cp); final Value<Boolean> loaded = new Value<>(false); final List<CompletionItem> items = new ArrayList<>(); final Registration reg = async.onSuccess(new Handler<Iterable<CompletionItem>>() { @Override/*w ww . j a v a2 s. co m*/ public void handle(Iterable<CompletionItem> result) { loaded.set(true); items.addAll(FluentIterable.from(result).toList()); } }); reg.remove(); if (!loaded.get()) { return false; } else { return items.isEmpty(); } }
From source file:com.tngtech.archunit.library.plantuml.PlantUmlParser.java
private List<String> filterOutComments(List<String> lines) { return FluentIterable.from(lines).filter(not(containsPattern("^\\s*'"))).toList(); }