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:Main.java

public static void fillComboBox(JComboBox<String> comboBox, String[] values, boolean isToClean,
        String firstElement) {//from   w  w  w. java  2  s .  c  om

    if (comboBox == null) {
        return;
    }

    if (isToClean) {
        comboBox.removeAllItems();
    }

    if (firstElement != null) {
        comboBox.addItem(firstElement);
    }

    Arrays.stream(values).forEach(val -> comboBox.addItem(val));
}

From source file:Main.java

/**
 * Places the given components in a horizontal Box with a glue at the end,
 * causing the components to align left.
 * @param components the components to add
 * @return the components in a horizontal Box, aligned left
 *///www. j  av a 2s . c o m
public static Box buildLeftAlignedRow(Component... components) {
    final Box result = Box.createHorizontalBox();
    Arrays.stream(components).forEach(result::add);
    result.add(Box.createHorizontalGlue());
    return result;
}

From source file:Main.java

/**
 * Places the given components in a horizontal Box with a glue at the front,
 * causing the components to align right.
 * @param components the components to add
 * @return the components in a horizontal box, aligned right
 *///ww  w . ja  v  a2  s.  co m
public static Box buildRightAlignedRow(Component... components) {
    final Box result = Box.createHorizontalBox();
    result.add(Box.createHorizontalGlue());
    Arrays.stream(components).forEach(result::add);
    return result;
}

From source file:Main.java

public static <T> Collection<T> removeNodes(T[] array, T sampleNode) {
    return Arrays.stream(array).filter((node) -> node != null ? !node.equals(sampleNode) : false)
            .collect(Collectors.toList());
}

From source file:com.hengyi.japp.tools.PYUtil.java

public static List<String> getFirstSpell(String cs) {
    if (isBlank(cs)) {
        return null;
    }/*from   w  w  w .  j a v a  2s . com*/
    List<String> result = null;
    List<Set<Character>> cs_fpys = cs.chars().mapToObj(i -> toHanyuPinyinStringArray((char) i))
            .map(a -> Arrays.stream(a).map(s -> s.charAt(0)).collect(Collectors.toSet()))
            .collect(Collectors.toList());
    for (Set<Character> fpys : cs_fpys) {
        if (result == null) {
            result = fpys.stream().map(String::valueOf).collect(Collectors.toList());
        } else {
            Stream<String> tmps = result.stream().flatMap(s -> fpys.stream().map(fpy -> s + fpy));
            result = tmps.collect(Collectors.toList());
        }
    }
    return result;
}

From source file:com.netflix.spinnaker.halyard.deploy.deployment.v1.DeployOption.java

public static DeployOption fromString(String name) {
    return Arrays.stream(values()).filter(o -> o.toString().equalsIgnoreCase(name)).findFirst()
            .orElseThrow(() -> new IllegalArgumentException("There is no DeployType with name " + name));
}

From source file:co.runrightfast.metrics.MetricType.java

public static String metricName(@NonNull final MetricType metricType, final String... names) {
    notEmpty(names);// w  w  w.ja  v a  2s  . c  om
    checkArgument(!Arrays.stream(names).filter(StringUtils::isBlank).findFirst().isPresent(),
            "any of the names cannot be blank");
    final StringBuilder sb = new StringBuilder(64);
    sb.append(metricType.name());
    Arrays.stream(names).forEach(n -> sb.append('.').append(n));
    return sb.toString();
}

From source file:com.twosigma.beakerx.kernel.msg.StacktraceHtmlPrinter.java

public static String[] print(String[] input) {
    String[] escaped = Arrays.stream(input).map(StringEscapeUtils::escapeHtml4).toArray(String[]::new);
    return INSTANCE.doPrint(escaped);
}

From source file:com.blackducksoftware.integration.hub.detect.util.EnumUtilExtension.java

public static <T extends Enum<T>> List<T> parseCommaDelimitted(String commaDelimitedEnumString,
        Class<T> enumClass) {
    return Arrays.stream(commaDelimitedEnumString.split(",")).map(String::trim).filter(StringUtils::isNotBlank)
            .map(token -> Enum.valueOf(enumClass, token)).collect(Collectors.toList());
}

From source file:com.epam.ta.reportportal.database.entity.user.UserRole.java

public static Optional<UserRole> findByName(String name) {
    return Arrays.stream(UserRole.values()).filter(role -> role.name().equals(name)).findAny();
}