RFR - JDK-8203703 String::transform (CSR Review)

Stephen Colebourne scolebourne at joda.org
Wed Sep 19 13:25:48 UTC 2018


On Tue, 18 Sep 2018 at 18:57, Jim Laskey <james.laskey at oracle.com> wrote:
>
> Please review the API for String::transform. The goal is to provide a String instance method to allow function application of custom transformations applied to an instance of String.
>
> csr: https://bugs.openjdk.java.net/browse/JDK-8203703
> jbs: https://bugs.openjdk.java.net/browse/JDK-8203442

The similar method in java.time.* is named `with`
https://download.java.net/java/early_access/jdk11/docs/api/java.base/java/time/LocalDate.html#with(java.time.temporal.TemporalAdjuster)

String capped =
  title.with(Example::naiveDropFirstWord);
       .with(Example::naiveTitleCase)
       .concat(".");

However, I note that this method is designed to return any type, not
just String (making it a different kind of method). But *why* return
any type? The motivation for doing so is not clear from the CSR.

Stephen


More information about the core-libs-dev mailing list