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:module.organization.domain.groups.PersistentUnitGroup.java
private static Optional<PersistentUnitGroup> select(Unit unit, final Set<AccountabilityType> memberTypes, final Set<AccountabilityType> childUnitTypes) { return FluentIterable.from(unit.getUnitGroupSet()).filter(new Predicate<PersistentUnitGroup>() { @Override// ww w . j av a 2 s. c o m public boolean apply(PersistentUnitGroup group) { return Objects.equals(group.getMemberAccountabilityTypeSet(), memberTypes) && Objects.equals(group.getChildUnitAccountabilityTypeSet(), childUnitTypes); } }).first(); }
From source file:org.jclouds.openstack.keystone.v2_0.domain.PaginatedCollection.java
@Override public Optional<Object> nextMarker() { return FluentIterable.from(getLinks()).filter(new Predicate<Link>() { @Override// w ww . ja va 2 s . c o m public boolean apply(Link link) { return Link.Relation.NEXT == link.getRelation(); } }).transform(new Function<Link, Optional<Object>>() { @Override public Optional<Object> apply(Link link) { Collection<String> markers = queryParser().apply(link.getHref().getRawQuery()).get("marker"); return Optional.<Object>fromNullable(markers == null ? null : Iterables.get(markers, 0)); } }).first().or(Optional.absent()); }
From source file:org.apache.aurora.scheduler.http.Services.java
@GET @Produces(MediaType.APPLICATION_JSON)// w w w . ja va2 s. co m public Response getServices() { return Response.ok().entity(FluentIterable.from(serviceManagers) .transformAndConcat(input -> input.servicesByState().values()).transform(SERVICE_TO_BEAN).toList()) .build(); }
From source file:org.apache.beam.runners.core.LateDataUtils.java
/** * Returns an {@code Iterable<WindowedValue<InputT>>} that only contains non-late input elements. *///from w w w. j a v a 2 s.c o m public static <K, V> Iterable<WindowedValue<V>> dropExpiredWindows(final K key, Iterable<WindowedValue<V>> elements, final TimerInternals timerInternals, final WindowingStrategy<?, ?> windowingStrategy, final CounterCell droppedDueToLateness) { return FluentIterable.from(elements).transformAndConcat( // Explode windows to filter out expired ones new Function<WindowedValue<V>, Iterable<WindowedValue<V>>>() { @Override public Iterable<WindowedValue<V>> apply(@Nullable WindowedValue<V> input) { if (input == null) { return null; } return input.explodeWindows(); } }).filter(new Predicate<WindowedValue<V>>() { @Override public boolean apply(@Nullable WindowedValue<V> input) { if (input == null) { // drop null elements. return false; } BoundedWindow window = Iterables.getOnlyElement(input.getWindows()); boolean expired = window.maxTimestamp().plus(windowingStrategy.getAllowedLateness()) .isBefore(timerInternals.currentInputWatermarkTime()); if (expired) { // The element is too late for this window. droppedDueToLateness.inc(); WindowTracing.debug( "GroupAlsoByWindow: Dropping element at {} for key: {}; " + "window: {} since it is too far behind inputWatermark: {}", input.getTimestamp(), key, window, timerInternals.currentInputWatermarkTime()); } // Keep the element if the window is not expired. return !expired; } }); }
From source file:net.sourceforge.fenixedu.domain.util.icalendar.EventBean.java
public String getLocation() { return rooms == null ? "Fenix" : Joiner.on("; ").join(FluentIterable.from(rooms).transform(new Function<Space, String>() { @Override/* w ww.j a v a 2 s. c om*/ public String apply(Space input) { return input.getName(); } }).toSet()); }
From source file:it.frob.auto.value.neuteredtostring.AutoValueNeuterToStringExtension.java
/** * Class constructor method generator.//from ww w .java 2s . co m * * @param properties the properties of the class constructor to generate. * @return a {@link MethodSpec} instance containing the class constructor. */ private static MethodSpec generateConstructor(Map<String, ExecutableElement> properties) { List<ParameterSpec> params = new ArrayList<ParameterSpec>(); for (Map.Entry<String, ExecutableElement> entry : properties.entrySet()) { TypeName typeName = TypeName.get(entry.getValue().getReturnType()); params.add(ParameterSpec.builder(typeName, entry.getKey()).build()); } String body = String.format("super(%s)", Joiner.on(", ") .join(FluentIterable .from(ImmutableRangeSet.of(Range.closedOpen(0, properties.size())) .asSet(DiscreteDomain.integers()).descendingSet()) .transform(new Function<Integer, String>() { @Override public String apply(Integer input) { return "$N"; } }))); return MethodSpec.constructorBuilder().addParameters(params) .addStatement(body, properties.keySet().toArray()).build(); }
From source file:google.registry.batch.DeleteProberDataAction.java
private static ImmutableSet<String> getProberRoidSuffixes() { return FluentIterable.from(getTldsOfType(TldType.TEST)).filter(new Predicate<String>() { @Override//from w w w .j a v a 2 s . c o m public boolean apply(String tld) { // Extra sanity check to prevent us from nuking prod data if a real TLD accidentally // gets set to type TEST. return tld.endsWith(".test"); } }).transform(new Function<String, String>() { @Override public String apply(String tld) { return Registry.get(tld).getRoidSuffix(); } }).toSet(); }
From source file:dagger.internal.codegen.writer.EnumWriter.java
@Override public Appendable write(Appendable appendable, Context context) throws IOException { context = context.createSubcontext(/*from w w w . ja v a 2 s . c o m*/ FluentIterable.from(nestedTypeWriters).transform(new Function<TypeWriter, ClassName>() { @Override public ClassName apply(TypeWriter input) { return input.name; } }).toSet()); writeAnnotations(appendable, context); writeModifiers(appendable).append("enum ").append(name.simpleName()); Iterator<TypeName> implementedTypesIterator = implementedTypes.iterator(); if (implementedTypesIterator.hasNext()) { appendable.append(" implements "); implementedTypesIterator.next().write(appendable, context); while (implementedTypesIterator.hasNext()) { appendable.append(", "); implementedTypesIterator.next().write(appendable, context); } } appendable.append(" {"); checkState(!constantWriters.isEmpty(), "Cannot write an enum with no constants."); appendable.append('\n'); ImmutableList<ConstantWriter> constantWriterList = ImmutableList.copyOf(constantWriters.values()); for (ConstantWriter constantWriter : constantWriterList.subList(0, constantWriterList.size() - 1)) { constantWriter.write(appendable, context); appendable.append(",\n"); } constantWriterList.get(constantWriterList.size() - 1).write(appendable, context); appendable.append(";\n"); if (!fieldWriters.isEmpty()) { appendable.append('\n'); } for (VariableWriter fieldWriter : fieldWriters.values()) { fieldWriter.write(new IndentingAppendable(appendable), context).append("\n"); } for (ConstructorWriter constructorWriter : constructorWriters) { appendable.append('\n'); if (!isDefaultConstructor(constructorWriter)) { constructorWriter.write(new IndentingAppendable(appendable), context); } } for (MethodWriter methodWriter : methodWriters) { appendable.append('\n'); methodWriter.write(new IndentingAppendable(appendable), context); } for (TypeWriter nestedTypeWriter : nestedTypeWriters) { appendable.append('\n'); nestedTypeWriter.write(new IndentingAppendable(appendable), context); } appendable.append("}\n"); return appendable; }
From source file:com.jeroensteenbeeke.andalite.java.analyzer.matchers.MethodMatcher.java
@Override public void describeTo(Description description) { description.appendText("denomination has method "); description.appendText(modifier.getOutput()); description.appendText(" "); description.appendText(type);//from ww w . j a v a 2 s . co m description.appendText(" "); description.appendText(name); description.appendText("("); description.appendText(Joiner.on(", ") .join(FluentIterable.from(descriptors).transform(ParameterDescriptor.toStringFunction()))); description.appendText(")"); }
From source file:com.spectralogic.ds3cli.views.csv.DetailedObjectsPhysicalView.java
@Override public String render(final GetDetailedObjectsResult obj) { final Iterable<DetailedS3Object> detailedS3Objects = obj.getResult(); if (detailedS3Objects == null || Iterables.isEmpty(detailedS3Objects)) { return "No objects returned"; }/* ww w .j a v a2 s . co m*/ final ImmutableList<String> headers = ImmutableList.of("Name", "Bucket", "Owner", "Size", "Type", "Creation Date", "Barcode", "State"); final FluentIterable<DetailedTapeInfo> objects = FluentIterable.from(detailedS3Objects) .filter(new Predicate<DetailedS3Object>() { @Override public boolean apply(@Nullable final DetailedS3Object input) { return input.getBlobs() != null && !Guard.isNullOrEmpty(input.getBlobs().getObjects()); } }).transformAndConcat(new DetailedDs3ObjectMapper()); return new CsvOutput<>(headers, objects, new CsvOutput.ContentFormatter<DetailedTapeInfo>() { @Override public Iterable<String> format(final DetailedTapeInfo content) { final ImmutableList.Builder<String> csvRow = ImmutableList.builder(); final DetailedS3Object detailedObject = content.getDetailedS3Object(); final Tape tape = content.getTape(); csvRow.add(nullGuard(detailedObject.getName())); csvRow.add(nullGuardToString(detailedObject.getBucketId())); csvRow.add(nullGuardToString(detailedObject.getOwner())); csvRow.add(nullGuardToString(detailedObject.getSize())); csvRow.add(nullGuardToString(detailedObject.getType())); csvRow.add(nullGuardFromDate(detailedObject.getCreationDate(), DATE_FORMAT)); csvRow.add(nullGuard(tape.getBarCode())); csvRow.add(nullGuardToString(tape.getState())); return csvRow.build(); } }).toString(); }