Example usage for java.util Arrays stream

List of usage examples for java.util Arrays stream

Introduction

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

Prototype

public static DoubleStream stream(double[] array) 

Source Link

Document

Returns a sequential DoubleStream with the specified array as its source.

Usage

From source file:io.engineblock.util.StrInterpolater.java

public StrInterpolater(ActivityDef... activityDefs) {
    Arrays.stream(activityDefs).map(ad -> ad.getParams().getStringStringMap()).forEach(multimap::add);
}

From source file:ServerMultipart.java

private static void multipartUpload(ServerSideMultipartManager multipart) {
    String uploadObject = "/" + mantaUsername + "/stor/multipart";

    // We catch network errors and handle them here
    try {//from w  ww .  j av a  2s. co m
        ServerSideMultipartUpload upload = multipart.initiateUpload(uploadObject);
        MantaMultipartUploadPart part1 = multipart.uploadPart(upload, 1, RandomUtils.nextBytes(5242880));
        MantaMultipartUploadPart part2 = multipart.uploadPart(upload, 2, RandomUtils.nextBytes(1000000));

        // Complete the process by instructing Manta to assemble the final object from its parts
        MantaMultipartUploadTuple[] parts = new MantaMultipartUploadTuple[] { part1, part2 };
        Stream<MantaMultipartUploadTuple> partsStream = Arrays.stream(parts);
        multipart.complete(upload, partsStream);

        System.out.println(uploadObject + " is now assembled!");
    } catch (IOException e) {
        // This catch block is for general network failures
        // For example, ServerSideMultipartUpload.initiateUpload can throw an IOException

        ContextedRuntimeException exception = new ContextedRuntimeException(
                "A network error occurred when doing a multipart upload to Manta.");
        exception.setContextValue("path", uploadObject);

        throw exception;
    }
}

From source file:hrytsenko.gscripts.App.java

private static void executeScripts(AppArgs args) {
    GroovyShell shell = createShell(args);

    Arrays.stream(EMBEDDED_SCRIPTS).forEach(script -> executeEmbeddedScript(shell, script));

    args.getScripts().stream().map(Paths::get).forEach(script -> executeCustomScript(shell, script));
}

From source file:cn.edu.zjnu.acm.judge.security.password.CombinePasswordEncoder.java

@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
    return Arrays.stream(encoders).anyMatch(encoder -> encoder.matches(rawPassword, encodedPassword));
}

From source file:com.cybernostics.jsp2thymeleaf.api.expressions.function.FunctionConverterSource.java

public FunctionConverterSource convertsMethodsUsingFormat(String methodFormat, String... inputFunctions) {
    Arrays.stream(inputFunctions)
            .map(method -> convertsMethodCall(method).toMethodCall(format(methodFormat, method)))
            .forEach(converter -> add(converter));
    return this;
}

From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.phpUnit.strategy.AssertConstantStrategy.java

static public boolean apply(@NotNull String methodName, @NotNull MethodReference reference,
        @NotNull ProblemsHolder holder) {
    boolean result = false;
    if (targetMapping.containsKey(methodName)) {
        final PsiElement[] arguments = reference.getParameters();
        if (arguments.length > 1) {
            for (final PsiElement argument : arguments) {
                if (argument instanceof ConstantReference) {
                    final String constantName = ((ConstantReference) argument).getName();
                    if (constantName != null) {
                        final String constantNameNormalized = constantName.toLowerCase();
                        if (targetConstants.contains(constantNameNormalized)) {
                            final String suggestedAssertion = String.format(targetMapping.get(methodName),
                                    StringUtils.capitalize(constantNameNormalized));
                            final String[] suggestedArguments = new String[arguments.length - 1];
                            suggestedArguments[0] = Arrays.stream(arguments).filter(a -> a != argument)
                                    .findFirst().get().getText();
                            if (arguments.length > 2) {
                                suggestedArguments[1] = arguments[2].getText();
                            }// w ww  .  ja v  a  2s .com
                            holder.registerProblem(reference, String.format(messagePattern, suggestedAssertion),
                                    new PhpUnitAssertFixer(suggestedAssertion, suggestedArguments));

                            result = true;
                            break;
                        }
                    }
                }
            }
        }
    }
    return result;
}

From source file:Main.java

/**
 * @param entries//  w  w w .  j  av a2s.  c om
 *            the <i>final</i> set of entries to add to the newly created
 *            <i>unmodifiable</i> map
 * @return an <i>unmodifiable</i> map with all given entries
 */
@SafeVarargs
public static <K, V> Map<K, V> map(Entry<K, V>... entries) {
    return Collections
            .unmodifiableMap(Arrays.stream(entries).collect(Collectors.toMap(Entry::getKey, Entry::getValue)));
}

From source file:com.cognifide.qa.bb.modules.BobcatRunModule.java

@Override
protected void configure() {
    String runmodes = System.getProperty("runmode", "default");
    String[] separateRunModes = StringUtils.split(runmodes, ",");
    List<String> modules = new ArrayList<>();
    TypeReference typeReference = new TypeReference<List<String>>() {
    };//from  w  w w.java2  s . c om
    Arrays.stream(separateRunModes).forEach(
            runmode -> modules.addAll(YamlReader.readFromTestResources("runmodes/" + runmode, typeReference)));
    modules.stream().forEach(this::installFromName);
}

From source file:com.github.rutledgepaulv.qbuilders.structures.FieldPath.java

public FieldPath append(String... path) {
    List<FieldNamespace> chain = new LinkedList<>();
    chain.addAll(this.chain);
    chain.addAll(Arrays.stream(path).map(FieldNamespace::new).collect(Collectors.toList()));
    return new FieldPath(chain);
}

From source file:org.zalando.problem.JacksonStackTraceProcessor.java

private Predicate<StackTraceElement> startsWith(final String... prefixes) {
    return element -> Arrays.stream(prefixes).anyMatch(prefix -> element.getClassName().startsWith(prefix));
}