Example usage for com.google.common.collect Iterables transform

List of usage examples for com.google.common.collect Iterables transform

Introduction

In this page you can find the example usage for com.google.common.collect Iterables transform.

Prototype

@CheckReturnValue
public static <F, T> Iterable<T> transform(final Iterable<F> fromIterable,
        final Function<? super F, ? extends T> function) 

Source Link

Document

Returns an iterable that applies function to each element of fromIterable .

Usage

From source file:org.semanticweb.elk.owlapi.proofs.OwlInternalJustifier.java

@Override
public Set<OWLAxiom> getJustification(Inference<?> inference) {
    return ImmutableSet.copyOf(Iterables.transform(internalJustifier_.getJustification(inference), this));
}

From source file:uk.ac.stfc.isis.ibex.configserver.json.EditableIocsConverter.java

@Override
public Collection<EditableIoc> convert(Map<String, IocParameters> value) throws ConversionException {
    return Lists.newArrayList(Iterables.transform(value.entrySet(),
            new Function<Map.Entry<String, IocParameters>, EditableIoc>() {

                @Override//from  w w w. jav  a2s  .c  o m
                public EditableIoc apply(Entry<String, IocParameters> entry) {
                    String name = entry.getKey();
                    IocParameters parameters = entry.getValue();

                    EditableIoc ioc = new EditableIoc(name);
                    if (parameters.getMacros() != null) {
                        ioc.setAvailableMacros(parameters.getMacros());
                    }

                    if (parameters.getPVs() != null) {
                        ioc.setAvailablePVs(parameters.getPVs());
                    }

                    if (parameters.getPVSets() != null) {
                        ioc.setAvailablePVSets(parameters.getPVSets());
                    }

                    if (parameters.getDescription() != null) {
                        ioc.setDescription(parameters.getDescription());
                    }

                    return ioc;
                }
            }));
}

From source file:org.polymap.rhei.fulltext.CrsTransformDecorator.java

@Override
public Iterable<JSONObject> search(String query, int maxResults) throws Exception {
    Iterable<JSONObject> results = next.search(query, maxResults);

    return Iterables.transform(results, new Function<JSONObject, JSONObject>() {
        public JSONObject apply(JSONObject input) {
            try {
                Geometry geom = (Geometry) input.opt(FIELD_GEOM);
                String srs = input.optString(FIELD_SRS);
                if (geom != null && srs != null) {
                    Geometry transformed = Geometries.transform(geom, Geometries.crs(srs), targetCrs);
                    input.put(FIELD_GEOM, transformed);
                }/*  w  w w. jav a2 s .  c  o  m*/
                return input;
            } catch (RuntimeException e) {
                throw e;
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    });
}

From source file:org.apache.aurora.scheduler.http.TransformationUtils.java

/**
 * Gets an optional task metadata./* ww  w  .j  a v a 2s  .  c o m*/
 *
 * @param task Task to get metadata from.
 * @return Present if task metadata exists, absent otherwise.
 */
public static Optional<String> getMetadata(ITaskConfig task) {
    if (task.isSetMetadata()) {
        Iterable<String> metadata = ImmutableSet
                .copyOf(Iterables.transform(task.getMetadata(), TransformationUtils.METADATA_TOSTRING));
        return Optional.of(Joiner.on(", ").join(Ordering.natural().sortedCopy(metadata)));
    }
    return Optional.absent();
}

From source file:cosmos.sql.impl.functions.FieldLimiter.java

public FieldLimiter(List<Field> fields) {
    limitingPredicate = new FieldLimitPredicate(
            Lists.newArrayList(Iterables.transform(fields, new Function<Field, String>() {
                @Override/*from  w  ww .  ja v  a  2s  .com*/
                public String apply(Field field) {
                    return field.toString();
                }
            })));

}

From source file:org.incode.module.note.dom.impl.note.NoteRepository.java

@Programmatic
public List<Note> findByNotable(final Object notable) {
    final List<NotableLink> links = linkRepository.findByNotable(notable);
    return Lists.newArrayList(Iterables.transform(links, NotableLink.Functions.note()));
}

From source file:es.usc.citius.hipster.thirdparty.graphs.jung.JUNGHipsterGraphAdapter.java

@Override
public Iterable<GraphEdge<V, E>> edges() {
    final Collection<E> edges = graph.getEdges();
    if (edges == null || edges.isEmpty()) {
        return Collections.emptyList();
    }/*from  w ww .j a  v a 2  s . com*/
    return Iterables.transform(edges, new Function<E, GraphEdge<V, E>>() {
        @Override
        public GraphEdge<V, E> apply(E edge) {
            return new GraphEdge<V, E>(graph.getSource(edge), graph.getDest(edge), edge);
        }
    });
}

From source file:com.google.errorprone.predicates.TypePredicates.java

/** Match types that are a sub-type of one of the given types. */
public static TypePredicate isDescendantOfAny(Iterable<String> types) {
    return new DescendantOfAny(Iterables.transform(types, GET_TYPE));
}

From source file:org.gradle.model.internal.manage.schema.extract.UnmanagedImplStructStrategy.java

protected <R> ModelSchema<R> createSchema(final ModelSchemaExtractionContext<R> extractionContext,
        Iterable<ModelPropertyExtractionResult<?>> propertyResults, Iterable<ModelSchemaAspect> aspects) {
    Iterable<ModelProperty<?>> properties = Iterables.transform(propertyResults,
            new Function<ModelPropertyExtractionResult<?>, ModelProperty<?>>() {
                @Override//w w  w  . ja  va  2  s .  c om
                public ModelProperty<?> apply(ModelPropertyExtractionResult<?> propertyResult) {
                    return propertyResult.getProperty();
                }
            });
    return new ModelUnmanagedImplStructSchema<R>(extractionContext.getType(), properties, aspects);
}

From source file:org.sonar.batch.duplication.DuplicationCache.java

public Iterable<String> componentKeys() {
    return Iterables.transform(cache.keySet(), new Function<Object, String>() {
        @Override/* www . j  a va2 s.c  om*/
        public String apply(Object input) {
            return input.toString();
        }
    });
}