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.errorprone.BugPatternIndexYamlWriter.java
void dump(Collection<Instance> patterns, Writer w) throws IOException { Map<String, List<Map<String, String>>> data = new TreeMap<>(Ordering.natural().reverse()); ListMultimap<String, BugPattern.Instance> index = index(patterns, new Function<Instance, String>() { @Override//from ww w . j a va2 s.c o m public String apply(Instance input) { return input.maturity.description + " : " + input.severity; } }); for (Entry<String, Collection<Instance>> entry : index.asMap().entrySet()) { data.put(entry.getKey(), FluentIterable.from(entry.getValue()).transform(new Function<Instance, Map<String, String>>() { @Override public Map<String, String> apply(Instance input) { return ImmutableMap.of("name", input.name, "summary", input.summary); } }).toSortedList(new Ordering<Map<String, String>>() { @Override public int compare(Map<String, String> left, Map<String, String> right) { return left.get("name").compareTo(right.get("name")); } })); } new Yaml().dump(data, w); }
From source file:com.b2international.index.lucene.FilteredIndexField.java
@Override public List<String> getValuesAsStringList(Document doc) { return FluentIterable.from(getValues(doc)).transform(Functions.toStringFunction()).toList(); }
From source file:dagger2.internal.codegen.writer.TypeNames.java
public static TypeName forTypeMirror(TypeMirror mirror) { return mirror.accept(new SimpleTypeVisitor6<TypeName, Void>() { @Override//from www.j av a 2 s . c o m protected TypeName defaultAction(TypeMirror e, Void p) { throw new IllegalArgumentException(e.toString()); } @Override public TypeName visitTypeVariable(TypeVariable t, Void p) { return TypeVariableName.fromTypeVariable(t); } @Override public ArrayTypeName visitArray(ArrayType t, Void p) { return new ArrayTypeName(t.getComponentType().accept(this, null)); } @Override public TypeName visitDeclared(DeclaredType t, Void p) { return t.getTypeArguments().isEmpty() ? ClassName.fromTypeElement((TypeElement) t.asElement()) : new ParameterizedTypeName(ClassName.fromTypeElement((TypeElement) t.asElement()), FluentIterable.from(t.getTypeArguments()).transform(FOR_TYPE_MIRROR)); } @Override public PrimitiveName visitPrimitive(PrimitiveType t, Void p) { return PrimitiveName.forTypeMirror(t); } @Override public WildcardName visitWildcard(WildcardType t, Void p) { return WildcardName.forTypeMirror(t); } @Override public NullName visitNull(NullType t, Void p) { return NullName.NULL; } @Override public TypeName visitNoType(NoType t, Void p) { switch (t.getKind()) { case VOID: return VoidName.VOID; case PACKAGE: throw new IllegalArgumentException(); default: throw new IllegalStateException(); } } }, null); }
From source file:google.registry.whois.NameserverLookupByIpCommand.java
@Override public WhoisResponse executeQuery(DateTime now) throws WhoisException { ImmutableList<HostResource> hosts = FluentIterable .from(queryNotDeleted(HostResource.class, now, "inetAddresses", ipAddress)) .filter(new Predicate<HostResource>() { @Override/*from ww w . j av a2s. c o m*/ public boolean apply(final HostResource host) { return Registries.findTldForName(InternetDomainName.from(host.getFullyQualifiedHostName())) .isPresent(); } }).toList(); if (hosts.isEmpty()) { throw new WhoisException(now, SC_NOT_FOUND, "No nameservers found."); } return new NameserverWhoisResponse(hosts, now); }
From source file:com.github.jsdossier.jscomp.DossierModuleRegistry.java
/** * Creates a new registry./*from w ww .java 2 s.c o m*/ * * @param commonJsModulePaths the set of source files that should be treated as a CommonJS * modules. All other source files will be treated as normal JS files. */ public DossierModuleRegistry(Iterable<Path> commonJsModulePaths) { this.commonJsModulePaths = FluentIterable.from(commonJsModulePaths).transform(Functions.toStringFunction()) .toSet(); this.fileSystem = commonJsModulePaths.iterator().hasNext() ? commonJsModulePaths.iterator().next().getFileSystem() : FileSystems.getDefault(); }
From source file:org.raml.jaxrs.parser.model.Utilities.java
public static FluentIterable<Parameter> getMultiPartFormDataParameter(ResourceMethod resourceMethod) { return FluentIterable.from(resourceMethod.getInvocable().getParameters()) .filter(new Predicate<Parameter>() { @Override//from w w w .ja v a 2 s. co m public boolean apply(@Nullable Parameter input) { return input.isAnnotationPresent(FormDataParam.class) && input.getRawType() != FormDataContentDisposition.class; } }); }
From source file:com.vilt.minium.impl.ExpressionWebElementsImpl.java
@Override public Iterable<WebElementsDriver<T>> webDrivers() { return FluentIterable.from(this).transform(new Function<WebElement, WebElementsDriver<T>>() { @Override/*ww w .ja v a2 s.co m*/ @Nullable @SuppressWarnings("unchecked") public WebElementsDriver<T> apply(@Nullable WebElement input) { return (WebElementsDriver<T>) ((DelegateWebElement) input).getWrappedDriver(); } }).toSet(); }
From source file:org.vincibean.salestaxes.util.PoiuytPriceCalculator.java
/** * Utility method for calculating the total amount of the taxes of a {@link Poiuyt}, taking into * account the duty or discount of the {@link Category}(ies) it belongs to. * @param poiuyt the {@link Poiuyt} object whose final price you intend to calculate. * @return the final price of the input {@link Poiuyt}. */// w w w . j av a 2 s .c o m public static double calculateTotalTaxesPerPoiuyt(final Poiuyt poiuyt) { double totalTaxes = 0; for (Double feeAmount : FluentIterable.from(poiuyt.getCategorySet()) .transform(createCategoryFeeCalculator())) { totalTaxes += feeAmount; } return poiuyt.getPrice() * totalTaxes / 100; }
From source file:org.sosy_lab.cpachecker.util.refinement.InfeasiblePrefix.java
public static InfeasiblePrefix buildForValueDomain(final ARGPath pInfeasiblePrefix, final List<ValueAnalysisInterpolant> pInterpolantSequence) { List<Set<String>> simpleInterpolantSequence = new ArrayList<>(); for (ValueAnalysisInterpolant itp : pInterpolantSequence) { simpleInterpolantSequence.add(FluentIterable.from(itp.getMemoryLocations()) .transform(MemoryLocation.FROM_MEMORYLOCATION_TO_STRING).toSet()); }/* ww w .j a v a 2 s . com*/ return new InfeasiblePrefix(pInfeasiblePrefix, Pair.zipList(pInfeasiblePrefix.asStatesList().subList(1, pInfeasiblePrefix.asStatesList().size()), simpleInterpolantSequence)); }
From source file:org.eclipse.mylyn.internal.gerrit.ui.GerritCompareUi.java
static CompareEditorInput getComparisonEditorInput(IEditorReference[] editorReferences, CompareEditorInput editorInput, Predicate<CompareEditorInput> predicate) { return FluentIterable.from(Lists.newArrayList(editorReferences)).filter(new Predicate<IEditorReference>() { public boolean apply(IEditorReference ref) { return ref.getId().equals("org.eclipse.compare.CompareEditor"); //$NON-NLS-1$ }/*from www.ja v a 2 s.c om*/ }).transform(new Function<IEditorReference, CompareEditorInput>() { public CompareEditorInput apply(IEditorReference reference) { try { return (CompareEditorInput) reference.getEditorInput(); } catch (PartInitException e) { handleError(e); } return null; } }).firstMatch(predicate).or(editorInput); }