Example usage for com.google.common.collect FluentIterable from

List of usage examples for com.google.common.collect FluentIterable from

Introduction

In this page you can find the example usage for com.google.common.collect FluentIterable from.

Prototype

@Deprecated
@CheckReturnValue
public static <E> FluentIterable<E> from(FluentIterable<E> iterable) 

Source Link

Document

Construct a fluent iterable from another fluent iterable.

Usage

From source file:com.salesforce.ide.ui.editors.apex.outline.ApexOutlineContentProvider.java

public static FluentIterable<Identifier> validIdentifiers(Iterable<Identifier> list) {
    return FluentIterable.from(list).filter(new Predicate<Identifier>() {

        @Override//w w w  . j ava  2s  .  c o  m
        public boolean apply(Identifier id) {
            return id != null;
        }
    });
}

From source file:org.eclipse.buildship.ui.view.execution.RunTestAction.java

@Override
public boolean isVisibleFor(NodeSelection selection) {
    return !selection.isEmpty() && FluentIterable.from(selection.toList(OperationItem.class))
            .anyMatch(TEST_OPERATION_ITEM_PREDICATE);
}

From source file:com.google.auto.factory.processor.Parameter.java

static Parameter forVariableElement(VariableElement variable, TypeMirror type) {
    ImmutableSet.Builder<String> qualifiers = ImmutableSet.builder();
    for (AnnotationMirror annotationMirror : variable.getAnnotationMirrors()) {
        DeclaredType annotationType = annotationMirror.getAnnotationType();
        if (annotationType.asElement().getAnnotation(Qualifier.class) != null) {
            qualifiers.add(Mirrors.getQualifiedName(annotationType).toString());
        }//  w ww  .jav a  2 s.  c  o m
    }
    // TODO(gak): check for only one qualifier rather than using the first
    return new Parameter(FluentIterable.from(qualifiers.build()).first(), type.toString(),
            variable.getSimpleName().toString());
}

From source file:io.airlift.discovery.server.ReplicatedDynamicStore.java

@Override
public void put(Id<Node> nodeId, DynamicAnnouncement announcement) {
    List<Service> services = FluentIterable.from(announcement.getServiceAnnouncements())
            .transform(toServiceWith(nodeId, announcement.getLocation(), announcement.getPool())).toList();

    byte[] key = nodeId.getBytes();
    byte[] value = codec.toJsonBytes(services);

    store.put(key, value, maxAge);//from ww w  .j  a v a2 s .  c  om
}

From source file:com.spectralogic.ds3cli.views.csv.DetailedObjectsView.java

private static String concatenateTapes(final BulkObjectList objects) {
    if (Guard.isNullOrEmpty(objects.getObjects())) {
        return "No Physical Placement";
    }/*from ww w  .j  ava2s  . co m*/

    final FluentIterable<String> iterable = FluentIterable.from(objects.getObjects())
            .filter(new Predicate<BulkObject>() {
                @Override
                public boolean apply(@Nullable final BulkObject bulkObject) {
                    return bulkObject.getPhysicalPlacement() != null
                            && !Guard.isNullOrEmpty(bulkObject.getPhysicalPlacement().getTapes());
                }
            }).transformAndConcat(new Function<BulkObject, Iterable<String>>() {
                @Nullable
                @Override
                public Iterable<String> apply(@Nullable final BulkObject bulkObject) {
                    return FluentIterable.from(bulkObject.getPhysicalPlacement().getTapes())
                            .transform(new Function<Tape, String>() {
                                @Nullable
                                @Override
                                public String apply(@Nullable final Tape tape) {
                                    return tape.getBarCode();
                                }
                            });
                }
            });

    return Joiner.on(TAPE_SEPARATOR).join(iterable);
}

From source file:info.archinnov.achilles.compound.ThriftCompoundKeyMapper.java

public Object fromCompositeToEmbeddedId(PropertyMeta idMeta, List<Component<?>> components, Object primaryKey) {
    if (log.isTraceEnabled()) {
        log.trace("Build compound primary key {} from composite components {}", idMeta.getPropertyName(),
                format(components));//from w w  w  .  j a v a2  s .  c  o m
    }

    List<Object> partitionComponents = idMeta.extractPartitionComponents(primaryKey);

    Object compoundPrimaryKey;
    List<Class<?>> componentClasses = idMeta.getClusteringComponentClasses();
    List<Serializer<Object>> serializers = FluentIterable.from(componentClasses).transform(classToSerializer)
            .toImmutableList();

    List<Object> componentValues = new ArrayList<Object>(partitionComponents);
    for (int i = 0; i < components.size(); i++) {
        Component<?> comp = components.get(i);
        componentValues.add(serializers.get(i).fromByteBuffer(comp.getBytes()));
    }

    compoundPrimaryKey = idMeta.decodeFromComponents(componentValues);

    log.trace("Built compound primary key : {}", compoundPrimaryKey);

    return compoundPrimaryKey;
}

From source file:com.jeroensteenbeeke.andalite.java.analyzer.expression.ArrayCreationExpression.java

@Override
public String toJavaString() {
    StringBuilder builder = new StringBuilder();
    builder.append("new ");
    builder.append(type.toJavaString());
    builder.append("[");
    if (!dimensions.isEmpty()) {
        builder.append(/*from   ww w  .j a  v a  2s.  co  m*/
                Joiner.on("][").join(FluentIterable.from(getDimensions()).transform(toJavaStringFunction())));
    }

    builder.append("]");

    return builder.toString();
}

From source file:org.immutables.generator.TypeHierarchyCollector.java

public ImmutableSet<String> implementedInterfaceNames() {
    return FluentIterable.from(implementedInterfaces).transform(ToNameOfTypeElement.FUNCTION).toSet();
}

From source file:com.twitter.aurora.scheduler.storage.mem.MemUpdateStore.java

@Override
public Set<JobUpdateConfiguration> fetchUpdateConfigs(String role) {
    return FluentIterable.from(configs.values()).filter(hasRole(role)).transform(DEEP_COPY).toSet();
}

From source file:dagger2.internal.codegen.writer.ClassWriter.java

@Override
public Appendable write(Appendable appendable, Context context) throws IOException {
    context = context.createSubcontext(/*w ww  . j av  a 2 s .  co  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("class ").append(name.simpleName());
    Writables.join(", ", typeParameters, "<", ">", appendable, context);
    if (supertype.isPresent()) {
        appendable.append(" extends ");
        supertype.get().write(appendable, context);
    }
    Writables.join(", ", implementedTypes, " implements ", "", appendable, context);
    appendable.append(" {");
    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;
}