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:org.jclouds.rest.functions.ReturnEmptyFluentIterableOnNotFoundOr404.java
public Object apply(Exception from) { Iterable<ResourceNotFoundException> throwables = Iterables.filter(Throwables.getCausalChain(from), ResourceNotFoundException.class); if (Iterables.size(throwables) >= 1) { return FluentIterable.from(ImmutableSet.of()); } else if (rto404.apply(from)) { return FluentIterable.from(ImmutableSet.of()); }//w w w.java2 s. co m throw Throwables.propagate(from); }
From source file:com.facebook.buck.json.JsonConcatenateStep.java
@Override public StepExecutionResult execute(final ExecutionContext context) throws IOException, InterruptedException { ImmutableSortedSet<Path> filesToConcatenate = FluentIterable.from(this.inputs) .transform(new Function<Path, Path>() { @Nullable/*from w w w .ja v a2s . co m*/ @Override public Path apply(Path input) { return filesystem.getRootPath().resolve(input); } }).toSortedSet(Ordering.natural()); Path destination = filesystem.getRootPath().resolve(output); new JsonConcatenator(filesToConcatenate, destination, filesystem).concatenate(); return StepExecutionResult.SUCCESS; }
From source file:com.google.gerrit.server.project.RefFilter.java
public List<T> filter(List<T> refs) throws BadRequestException { FluentIterable<T> results = FluentIterable.from(refs); if (!Strings.isNullOrEmpty(matchSubstring)) { results = results.filter(new SubstringPredicate(matchSubstring)); } else if (!Strings.isNullOrEmpty(matchRegex)) { results = results.filter(new RegexPredicate(matchRegex)); }/*from w w w.j av a 2 s . c o m*/ if (start > 0) { results = results.skip(start); } if (limit > 0) { results = results.limit(limit); } return results.toList(); }
From source file:com.google.api.tools.framework.model.testing.BaselineDiffer.java
private static void addOutput(List<String> output, final String prefix, String text) { output.addAll(// w w w . j a va 2 s.c om FluentIterable.from(LINE_SPLITTER.split(text.trim())).transform(new Function<String, String>() { @Override public String apply(String input) { return prefix + input; } }).toList()); }
From source file:google.registry.model.ofy.AugmentedDeleter.java
@Override public Result<Void> entities(Object... entities) { handleDeletion(FluentIterable.from(asList(entities)).transform(OBJECTS_TO_KEYS)); return delegate.entities(entities); }
From source file:org.jclouds.ultradns.ws.xml.DirectionalPoolRecordDetailListHandler.java
@Override public FluentIterable<DirectionalPoolRecordDetail> getResult() { return FluentIterable.from(drs.build()); }
From source file:org.mayocat.attachment.AttachmentDataLoader.java
public <E extends Entity> void loadList(List<EntityData<E>> entities, LoadingOption... options) { List<LoadingOption> optionsAsList = Arrays.asList(options); List<Attachment> attachments; if (optionsAsList.contains(AttachmentLoadingOptions.FEATURED_IMAGE_ONLY)) { // Featured image only : we ignore all other attachments List<UUID> imageIds = FluentIterable.from(entities).transform(new Function<EntityData<E>, UUID>() { public UUID apply(EntityData<E> input) { if (!HasFeaturedImage.class.isAssignableFrom(input.getEntity().getClass())) { throw new RuntimeException( "Failed to load attachment list with featured image only option : entity does not implement HasFeaturedImage"); }//w w w. ja va 2 s . c om return ((HasFeaturedImage) input.getEntity()).getFeaturedImageId(); } }).filter(Predicates.notNull()).toList(); attachments = imageIds.size() > 0 ? this.attachmentStore.findByIds(imageIds) : Collections.<Attachment>emptyList(); } else { // All attachments for the list List<UUID> ids = FluentIterable.from(entities).transform(new Function<EntityData<E>, UUID>() { public UUID apply(EntityData<E> input) { return input.getEntity().getId(); } }).toList(); attachments = ids.size() > 0 ? this.attachmentStore.findAllChildrenOfParentIds(ids) : Collections.<Attachment>emptyList(); } for (final EntityData entity : entities) { List<Attachment> thisEntityAttachments = FluentIterable.from(attachments) .filter(new Predicate<Attachment>() { public boolean apply(Attachment attachment) { return entity.getEntity().getId().equals(attachment.getParentId()); } }).toList(); entity.setChildren(Attachment.class, thisEntityAttachments); } }
From source file:org.polymap.rhei.fulltext.LogQueryDecorator.java
@Override public Iterable<JSONObject> search(String query, int maxResults) throws Exception { Timer timer = new Timer(); log.info("Search: " + query); Iterable<JSONObject> results = next.search(query, maxResults); log.info("Search: " + FluentIterable.from(results).size() + " (" + timer.elapsedTime() + "ms)"); return results; }
From source file:com.bazaarvoice.dropwizard.caching.example.ExampleResource.java
@POST @Path("/test2") @CacheGroup("otterpop") @IncludeBodyInCacheKey/* w ww. j a v a2 s .co m*/ public List<ExampleResult> postIt(List<Integer> values) { return FluentIterable.from(values).transform(new Function<Integer, ExampleResult>() { public ExampleResult apply(Integer input) { return new ExampleResult(input); } }).toList(); }
From source file:org.androidtransfuse.adapter.element.ASTElementAnnotation.java
@Override public ImmutableSet<String> getPropertyNames() { return FluentIterable.from(annotationMirror.getElementValues().keySet()).transform(new ExtractElementName()) .toSet();//from ww w .j a v a2s . c o m }