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:com.example.app.profile.ui.user.LoginLandingLinks.java

/**
 * Get available links.//from  w  ww.j  av a2  s  .co m
 *
 * @param currentUser the current user.
 * @param lc the locale context.
 *
 * @return the list of links.
 */
static List<Link> getAvailableLinks(User currentUser, LocaleContext lc) {
    final DAOs daos = new DAOs();
    final List<Membership> memberships = daos.profileDAO.getMembershipsForUser(currentUser,
            "membership.lastModTime desc", AppUtil.UTC);
    return Arrays.stream(LoginLandingLinks.values())
            .map(availbaleLinks -> availbaleLinks.getLink(memberships, lc))
            .flatMap(link -> link.map(Stream::of).orElseGet(Stream::empty)).collect(Collectors.toList());

}

From source file:com.appdynamics.cloudfoundry.appdservicebroker.catalog.PlanMetadata.java

PlanMetadata bullets(String... bullets) {
    synchronized (this.monitor) {
        if (this.bullets == null) {
            this.bullets = new ArrayList<>();
        }// w  w w. jav  a  2  s . co m

        Arrays.stream(bullets).forEach(this.bullets::add);
        return this;
    }
}

From source file:org.echocat.marquardt.example.keyprovisioning.KeyFileReadingTrustedKeysProvider.java

private Collection<PublicKey> loadKeys(final String publicKeyFiles) {
    return Arrays.stream(publicKeyFiles.split(",")).map(p -> loadPublicKey(p.trim()))
            .collect(Collectors.toList());
}

From source file:com.bwc.ora.views.LabelPopupMenu.java

private void initMenu() {
    //determine if the point clicked already has an annotation
    boolean hasAnnotationAlready = hasAnnoationAlready();

    if (hasAnnotationAlready) {
        //add label to allow users to deselect the label for a given peak
        JMenuItem nonItem = new JMenuItem("Remove Label");
        nonItem.addActionListener(e -> {
            removeAnnotation();//from  w w  w.  ja  va 2 s.c o m
            lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations());
        });
        add(nonItem);
    }

    //add list of possible labels for a point to the popup menu
    Arrays.stream(RetinalBand.values()).map(RetinalBand::toString).map(label -> {
        XYPointerAnnotation pointer = new XYPointerAnnotation(label,
                item.getDataset().getXValue(item.getSeriesIndex(), item.getItem()),
                item.getDataset().getYValue(item.getSeriesIndex(), item.getItem()), 0);
        pointer.setBaseRadius(35.0);
        pointer.setTipRadius(10.0);
        pointer.setFont(new Font("SansSerif", Font.PLAIN, 9));
        pointer.setPaint(Color.blue);
        pointer.setTextAnchor(TextAnchor.CENTER_LEFT);
        JMenuItem l = new JMenuItem(label);
        l.addActionListener(e -> {
            if (hasAnnotationAlready) {
                removeAnnotation();
            }
            chartPanel.getChart().getXYPlot().addAnnotation(pointer);
            lrp.setAnnotations(LrpDisplayFrame.getInstance().getAnnotations());
        });
        return l;
    }).forEach(this::add);
}

From source file:com.netflix.spinnaker.halyard.config.validate.v1.DeploymentConfigurationValidator.java

@Override
public void validate(ConfigProblemSetBuilder p, DeploymentConfiguration n) {
    String timezone = n.getTimezone();

    if (Arrays.stream(TimeZone.getAvailableIDs()).noneMatch(t -> t.equals(timezone))) {
        p.addProblem(Problem.Severity.ERROR,
                "Timezone " + timezone + " does not match any known canonical timezone ID").setRemediation(
                        "Pick a timezone from those listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones");
    }//from  w w w .  java2 s .c  om

    String version = n.getVersion();
    Versions versions = versionsService.getVersions();

    if (StringUtils.isEmpty(version)) {
        p.addProblem(Problem.Severity.WARNING, "You have not yet selected a version of Spinnaker to deploy.",
                "version");
        return;
    }

    Optional<Versions.IllegalVersion> illegalVersion = versions.getIllegalVersions().stream()
            .filter(v -> v.getVersion().equals(version)).findAny();

    if (illegalVersion.isPresent()) {
        p.addProblem(Problem.Severity.ERROR, "Version \"" + version
                + "\" may no longer be deployed with Halyard: " + illegalVersion.get().getReason());
        return;
    }

    try {
        versionsService.getBillOfMaterials(version);
    } catch (HalException e) {
        p.extend(e);
        return;
    } catch (Exception e) {
        p.addProblem(Problem.Severity.FATAL,
                "Unexpected error trying to validate version \"" + version + "\": " + e.getMessage(),
                "version");
        return;
    }

    boolean isReleased = versions.getVersions().stream().anyMatch(v -> Objects.equals(v.getVersion(), version));

    if (!isReleased) {
        // Checks if version is of the form X.Y.Z
        if (version.matches("\\d+\\.\\d+\\.\\d+")) {
            String majorMinor = Versions.toMajorMinor(version);
            Optional<Versions.Version> patchVersion = versions.getVersions().stream()
                    .map(v -> new ImmutablePair<>(v, Versions.toMajorMinor(v.getVersion())))
                    .filter(v -> v.getRight() != null).filter(v -> v.getRight().equals(majorMinor))
                    .map(ImmutablePair::getLeft).findFirst();

            if (patchVersion.isPresent()) {
                p.addProblem(Problem.Severity.WARNING,
                        "Version \"" + version + "\" was patched by \"" + patchVersion.get().getVersion()
                                + "\". Please upgrade when possible.")
                        .setRemediation("https://spinnaker.io/setup/install/upgrades/");
            } else {
                p.addProblem(Problem.Severity.WARNING, "Version \"" + version
                        + "\" is no longer supported by the Spinnaker team. Please upgrade when possible.")
                        .setRemediation("https://spinnaker.io/setup/install/upgrades/");
            }
        } else {
            p.addProblem(Problem.Severity.WARNING,
                    "Version \"" + version + "\" is not a released (validated) version of Spinnaker.",
                    "version");
        }
    }
}

From source file:com.dhatim.io.dropwizard.metrics.elasticsearch.ElasticSearchReporterFactory.java

@Override
public ScheduledReporter build(MetricRegistry registry) {
    try {//  w w  w  .  j  av a  2s . co  m
        String[] hosts = Arrays.stream(servers).map(s -> s.host + ":" + s.port).toArray(String[]::new);

        return ElasticsearchReporter.forRegistry(registry).hosts(hosts).prefixedWith(prefix).index(index)
                .indexDateFormat(indexDateFormat).additionalFields(additionalFields).build();
    } catch (IOException e) {
        throw new RuntimeException("can't build elasticsearch reporter", e);
    }
}

From source file:com.github.ljtfreitas.restify.http.spring.contract.FormParameters.java

public FormParameters(Parameter... parameters) {
    Arrays.stream(parameters).forEach(p -> map.add(p.name(), p.value()));
}

From source file:com.offbynull.voip.kademlia.model.RouteTreeNode.java

public RouteTreeNode(BitString prefix, int suffixLen, KBucket[] buckets) {
    Validate.notNull(prefix);/*from   www.j  a va  2s  .  co  m*/
    Validate.notNull(buckets);
    Validate.noNullElements(buckets);
    Validate.isTrue(suffixLen > 0);

    this.prefix = prefix;
    this.suffixLen = suffixLen;
    this.branches = new ArrayList<>(buckets.length);
    Arrays.stream(buckets).map(x -> new RouteTreeBucketBranch(x)).forEachOrdered(branches::add);
}

From source file:com.github.braully.web.DescriptorExposedEntity.java

public DescriptorExposedEntity hiddenList(String... hiddenProperties) {
    if (hiddenProperties != null) {
        Arrays.stream(hiddenProperties).forEach(hp -> this.hiddenListProperties.add(hp));
    }//from w ww  . j  a va2s.co  m
    return this;
}

From source file:edu.wpi.checksims.token.tokenizer.CharTokenizer.java

/**
 * Split a string into character tokens.
 *
 * @param string String to split/*from w  w w . j  av a2 s.c om*/
 * @return Input string, with a single token representing each character
 */
@Override
public TokenList splitFile(String string) {
    checkNotNull(string);

    TokenList toReturn = new TokenList(this.getType());

    char[] chars = string.toCharArray();

    Arrays.stream(ArrayUtils.toObject(chars))
            .map((character) -> new ConcreteToken(character, TokenType.CHARACTER))
            .forEachOrdered(toReturn::add);

    return toReturn;
}