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:com.baifendian.swordfish.execserver.job.storm.StormSubmitArgsUtil.java

private static List<String> sqlArgs(StormParam stormParam) {
    StormSqlParam stormSqlParam = (StormSqlParam) stormParam.getStormParam();
    List<String> args = new ArrayList<>();
    args.add(SQL);//  w  w  w. ja  v a 2s.c om

    args.add(stormSqlParam.getSqlFile().getRes());

    args.add(stormParam.getTopologyName());
    //add Jars
    List<ResourceInfo> jars = stormSqlParam.getJars();
    if (CollectionUtils.isNotEmpty(jars)) {
        args.add(JARS);
        args.add(StringUtils.join(jars.stream().map(p -> p.getRes()).toArray(), ","));
    }

    if (StringUtils.isNotEmpty(stormSqlParam.getArtifacts())) {
        args.add(ARTIFACTS);
        args.add(stormSqlParam.getArtifacts());
    }

    if (StringUtils.isNotEmpty(stormSqlParam.getArtifactRepositories())) {
        args.add(ARTIFACTREPOSITORIES);
        args.add(stormSqlParam.getArtifactRepositories());
    }

    return args;
}

From source file:io.rhiot.cloudplatform.service.binding.OperationBinding.java

static OperationBinding operationBinding(PayloadEncoding payloadEncoding, String channel,
        byte[] incomingPayload, Map<String, Object> headers, Registry registry) {
    String rawChannel = channel.substring(channel.lastIndexOf('/') + 1);
    String[] channelParts = rawChannel.split("\\.");
    String service = channelParts[0];
    String operation = channelParts[1];

    List<Object> arguments = new LinkedList<>(asList(channelParts).subList(2, channelParts.length));

    for (Map.Entry<String, Object> header : headers.entrySet()) {
        if (header.getKey().startsWith("RHIOT_ARG")) {
            arguments.add(header.getValue());
        }/*from   w w  w .  ja  va 2 s  .c  o  m*/
    }

    Object bean = registry.lookupByName(service);
    Validate.notNull(bean, "Cannot find service with name '%s'.", service);
    Class beanType = bean.getClass();

    LOG.debug("Detected service bean type {} for operation: {}", beanType, operation);
    List<Method> beanMethods = new ArrayList<>(asList(beanType.getDeclaredMethods()));
    beanMethods.addAll(asList(beanType.getMethods()));
    Method operationMethod = beanMethods.stream().filter(method -> method.getName().equals(operation)).findAny()
            .get();

    if (incomingPayload != null && incomingPayload.length > 0) {
        Object payload = incomingPayload;
        if (operationMethod.getParameterTypes()[operationMethod.getParameterTypes().length
                - 1] != byte[].class) {
            payload = payloadEncoding.decode(incomingPayload);
        }
        arguments.add(payload);
    }
    return new OperationBinding(service, operation, arguments, operationMethod);
}

From source file:com.baifendian.swordfish.execserver.job.spark.SparkSubmitArgsUtil.java

private static String getFilesStr(List<ResourceInfo> files, boolean isSymbolic) {
    if (files == null) {
        return StringUtils.EMPTY;
    }//from www  . j  ava  2s.  c  o  m

    if (isSymbolic) {
        return StringUtils.join(files.stream().map(p -> p.getSymbolicRes()).toArray(), ",");
    }

    return StringUtils.join(files.stream().map(p -> p.getRes()).toArray(), ",");
}

From source file:com.github.anba.es6draft.util.TestGlobals.java

private static Stream<String> streamNonEmpty(List<?> c) {
    return c.stream().filter(Objects::nonNull).map(Object::toString).filter(not(String::isEmpty));
}

From source file:it.reply.orchestrator.controller.ControllerTestUtils.java

public static List<Resource> createResources(Deployment deployment, int total, boolean sorted) {
    List<Resource> resources = Lists.newArrayList();
    for (int i = 0; i < total; ++i) {
        resources.add(createResource(deployment));
    }/*from w  w  w . j av  a 2s  . c  om*/

    if (sorted) {
        resources.stream().sorted(new Comparator<Resource>() {

            @Override
            public int compare(Resource o1, Resource o2) {
                return o1.getCreated().compareTo(o2.getCreated());
            }
        }).collect(Collectors.toList());
    }

    return resources;
}

From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java

public static final boolean isChildListImport(final List<ComplexTypeChild> children) {
    final boolean value = children.stream().filter(ctc -> ctc.isList()).findFirst().isPresent();
    return value;
}

From source file:com.baifendian.swordfish.execserver.job.storm.StormSubmitArgsUtil.java

private static List<String> jarArgs(StormJarParam stormJarParam) {
    List<String> args = new ArrayList<>();
    args.add(JAR);//from w w w.jav  a2s  .c  om

    //add mainJar
    args.add(stormJarParam.getMainJar().getRes());

    //add mainClass
    args.add(stormJarParam.getMainClass());

    //add Jars
    List<ResourceInfo> jars = stormJarParam.getJars();
    if (CollectionUtils.isNotEmpty(jars)) {
        args.add(JARS);
        args.add(StringUtils.join(jars.stream().map(p -> p.getRes()).toArray(), ","));
    }

    if (StringUtils.isNotEmpty(stormJarParam.getArgs())) {
        args.add(stormJarParam.getArgs());
    }

    if (StringUtils.isNotEmpty(stormJarParam.getArtifacts())) {
        args.add(ARTIFACTS);
        args.add(stormJarParam.getArtifacts());
    }

    if (StringUtils.isNotEmpty(stormJarParam.getArtifactRepositories())) {
        args.add(ARTIFACTREPOSITORIES);
        args.add(stormJarParam.getArtifactRepositories());
    }

    return args;

}

From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java

public static void validateNoStaticColumnsForView(AptUtils aptUtils, TypeName rawClassType,
        List<TypeParsingResult> parsingResults) {
    final boolean hasStatic = parsingResults.stream().filter(x -> (x.context.columnType == ColumnType.STATIC
            || x.context.columnType == ColumnType.STATIC_COUNTER)).count() > 0;

    aptUtils.validateFalse(hasStatic,/*from   w w  w.  j a va 2 s . c  o m*/
            "The class '%s' cannot have static columns because it is a materialized view", rawClassType);
}

From source file:info.archinnov.achilles.internals.parser.validator.BeanValidator.java

public static void validateStaticColumns(AptUtils aptUtils, TypeName rawClassType,
        List<TypeParsingResult> parsingResults) {
    final boolean hasStatic = parsingResults.stream().filter(x -> (x.context.columnType == ColumnType.STATIC
            || x.context.columnType == ColumnType.STATIC_COUNTER)).count() > 0;

    final boolean hasClustering = parsingResults.stream()
            .filter(x -> x.context.columnType == ColumnType.CLUSTERING).count() > 0;
    if (hasStatic) {
        aptUtils.validateTrue(hasClustering,
                "The class '%s' cannot have static columns without at least 1 clustering column", rawClassType);
    }//from  w ww  .ja va2s .  c  om
}

From source file:de.metas.ui.web.window.datatypes.json.filters.JSONDocumentFilter.java

public static final List<JSONDocumentFilter> ofList(final List<DocumentFilter> filters) {
    if (filters == null || filters.isEmpty()) {
        return ImmutableList.of();
    }// ww  w. j av  a2  s  .  c  o  m

    return filters.stream().map(filter -> of(filter)).collect(GuavaCollectors.toImmutableList());
}