Example usage for java.util List stream

List of usage examples for java.util List stream

Introduction

In this page you can find the example usage for java.util List stream.

Prototype

default Stream<E> stream() 

Source Link

Document

Returns a sequential Stream with this collection as its source.

Usage

From source file:org.keycloak.connections.httpclient.ProxyMappings.java

/**
 * Creates a new  {@link ProxyMappings} from the provided {@code List} of proxy mapping strings.
 * <p>//from   ww  w. java  2 s.  c om
 *
 * @param proxyMappings
 */
public static ProxyMappings valueOf(List<String> proxyMappings) {

    if (proxyMappings == null || proxyMappings.isEmpty()) {
        return EMPTY_MAPPING;
    }

    List<ProxyMapping> entries = proxyMappings.stream() //
            .map(ProxyMapping::valueOf) //
            .collect(Collectors.toList());

    return new ProxyMappings(entries);
}

From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java

public static List<ModelFormula> getFormulas(List<? extends Model> models) {
    return models.stream().map(m -> m.getFormula()).collect(Collectors.toList());
}

From source file:com.epam.catgenome.util.ProteinSequenceUtils.java

/**
 * Provides reverse complement operation on sequence, represented by List of {@link Sequence}.
 *
 * @param sequences nucleotide sequence//from w  w w  .j a  v  a  2s .c  o  m
 * @return reversed complement nucleotide sequence, represented by a List of {@link Sequence}
 */
public static List<Sequence> reverseComplement(final List<Sequence> sequences) {
    List<String> complement = sequences.stream().map(Sequence::getText).map(ProteinSequenceUtils::complement)
            .collect(Collectors.toList());
    Collections.reverse(complement);

    List<Sequence> result = new ArrayList<>(sequences.size());
    for (int i = 0; i < sequences.size(); i++) {
        Sequence nucleotide = sequences.get(sequences.size() - 1 - i);
        result.add(new Sequence(nucleotide.getStartIndex(), nucleotide.getEndIndex(), complement.get(i)));
    }

    return result;
}

From source file:com.fizzed.blaze.internal.DependencyHelper.java

/**
 * Get the dependency list from the application configuration file.
 * @param config/*from w w w. j  a v  a2s  . c om*/
 * @return 
 */
static public List<Dependency> applicationDependencies(Config config) {
    List<String> ds = config.valueList(Config.KEY_DEPENDENCIES).getOrNull();

    if (ds == null || ds.isEmpty()) {
        return null;
    }

    List<Dependency> dependencies = new ArrayList<>(ds.size());

    ds.stream().forEach((d) -> {
        dependencies.add(Dependency.parse(d));
    });

    return dependencies;
}

From source file:edu.usu.sdl.openstorefront.core.view.ArticleView.java

public static List<ArticleView> toViewList(List<AttributeCode> attributes) {
    List<ArticleView> views = new ArrayList<>();
    attributes.stream().forEach((attribute) -> {
        views.add(ArticleView.toView(attribute));
    });//from  ww  w . j av  a 2 s. c  o m
    return views;
}

From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java

public static List<String> getNames(List<? extends Nameable> nameables) {
    return nameables.stream().map(n -> n.getName()).collect(Collectors.toList());
}

From source file:com.wrmsr.search.dsl.util.DerivedSuppliers.java

private static void compileConstructor(ClassDefinition classDefinition,
        Map<String, FieldDefinition> classFieldDefinitionMap, List<TargetParameter> targetParameters)
        throws ReflectiveOperationException {
    List<Parameter> constructorParameters = targetParameters.stream()
            .map(p -> arg(p.name, classFieldDefinitionMap.get(p.name).getType())).collect(toImmutableList());
    MethodDefinition methodDefinition = classDefinition.declareConstructor(a(PUBLIC), constructorParameters);
    methodDefinition.declareAnnotation(Inject.class);

    for (int i = 0; i < targetParameters.size(); ++i) {
        TargetParameter targetParameter = targetParameters.get(i);
        for (Annotation annotation : targetParameter.annotations) {
            cloneParameterAnnotation(methodDefinition, i, annotation);
        }/* w  ww .  java 2  s .  c o  m*/
    }

    Scope scope = methodDefinition.getScope();
    BytecodeBlock body = methodDefinition.getBody();

    body.getVariable(scope.getThis()).invokeConstructor(Object.class);
    for (TargetParameter targetParameter : targetParameters) {
        body.getVariable(scope.getThis()).getVariable(scope.getVariable(targetParameter.name))
                .putField(classFieldDefinitionMap.get(targetParameter.name));
    }
    body.ret();
}

From source file:de.bund.bfr.knime.pmmlite.core.PmmUtils.java

public static <V extends Identifiable> List<V> getById(List<V> identifiables, Set<String> ids) {
    return identifiables.stream().filter(i -> ids.contains(i.getId())).collect(Collectors.toList());
}

From source file:de.bund.bfr.math.MultivariateOptimization.java

public static MultivariateOptimization createLodOptimizer(String formula, List<String> parameters,
        List<Double> targetValues, Map<String, List<Double>> variableValues, double levelOfDetection)
        throws ParseException {
    String sdParam = parameters.stream().collect(Collectors.joining());
    List<String> params = Stream.concat(parameters.stream(), Stream.of(sdParam)).collect(Collectors.toList());

    return new MultivariateOptimization(params, sdParam,
            new LodFunction(formula, params, variableValues, targetValues, levelOfDetection, sdParam));
}

From source file:com.simiacryptus.mindseye.applications.HadoopUtil.java

/**
 * Gets files./*from   w ww.  ja  v  a2 s.com*/
 *
 * @param file the file
 * @return the files
 */
public static List<CharSequence> getFiles(CharSequence file) {
    try {
        FileSystem fileSystem = getFileSystem(file);
        Path path = new Path(file.toString());
        if (!fileSystem.exists(path))
            throw new IllegalStateException(path + " does not exist");
        List<CharSequence> collect = toStream(fileSystem.listFiles(path, false)).map(FileStatus::getPath)
                .map(Path::toString).collect(Collectors.toList());
        collect.stream().forEach(child -> {
            try {
                if (!fileSystem.exists(new Path(child.toString())))
                    throw new IllegalStateException(child + " does not exist");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        });
        return collect;
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}