You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/05/20 14:51:50 UTC
(commons-text) branch master updated (3f05bf34 -> ec0845e5)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
from 3f05bf34 Bump org.apache.commons:commons-parent from 83 to 84
new 70cecfbc Interface StringLookup now extends UnaryOperator<String>
new 7a799b2d Interface StringLookup now extends UnaryOperator<String>
new 98aae9ad Interface TextRandomProvider extends IntUnaryOperator
new ec0845e5 Bump properties for the next version
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
pom.xml | 8 ++--
src/changes/changes.xml | 4 +-
.../apache/commons/text/RandomStringGenerator.java | 4 +-
.../org/apache/commons/text/StrSubstitutor.java | 2 +-
.../org/apache/commons/text/StringSubstitutor.java | 2 +-
.../apache/commons/text/TextRandomProvider.java | 34 +++++++++++----
.../apache/commons/text/lookup/BiStringLookup.java | 2 +-
.../text/lookup/InterpolatorStringLookup.java | 4 +-
.../text/lookup/JavaPlatformStringLookup.java | 2 +-
.../apache/commons/text/lookup/StringLookup.java | 37 ++++++++++++++++-
.../org/apache/commons/text/StrLookupTest.java | 48 +++++++++++-----------
.../apache/commons/text/StringSubstitutorTest.java | 1 +
...ubstitutorWithInterpolatorStringLookupTest.java | 1 +
.../text/lookup/Base64DecoderStringLookupTest.java | 4 +-
.../text/lookup/Base64EncoderStringLookupTest.java | 4 +-
.../text/lookup/BiFunctionStringLookupTest.java | 8 ++--
.../text/lookup/ConstantStringLookupBasicTest.java | 8 ++--
.../text/lookup/ConstantStringLookupTest.java | 16 ++++----
.../commons/text/lookup/DateStringLookupTest.java | 6 +--
.../commons/text/lookup/DnsStringLookupTest.java | 12 +++---
.../EnvironmentVariableStringLookupTest.java | 6 +--
.../commons/text/lookup/FileStringLookupTest.java | 26 ++++++------
.../text/lookup/FunctionStringLookupTest.java | 8 ++--
.../InetAddressStringLookupLocalHostTest.java | 10 ++---
...InetAddressStringLookupLoopbackAddressTest.java | 10 ++---
.../text/lookup/InterpolatorStringLookupTest.java | 20 ++++-----
.../text/lookup/JavaPlatformStringLookupTest.java | 6 +--
.../commons/text/lookup/NullStringLookupTest.java | 4 +-
.../text/lookup/PropertiesStringLookupTest.java | 34 +++++++--------
.../lookup/ResourceBundleStringLookupTest.java | 18 ++++----
.../text/lookup/ScriptStringLookupTest.java | 14 +++----
.../lookup/SystemPropertyStringLookupTest.java | 4 +-
.../text/lookup/UrlDecoderStringLookupTest.java | 10 ++---
.../text/lookup/UrlEncoderStringLookupTest.java | 6 +--
.../commons/text/lookup/UrlStringLookupTest.java | 16 ++++----
.../text/lookup/XmlDecoderStringLookupTest.java | 4 +-
.../text/lookup/XmlEncoderStringLookupTest.java | 4 +-
.../commons/text/lookup/XmlStringLookupTest.java | 24 +++++------
38 files changed, 244 insertions(+), 187 deletions(-)
(commons-text) 04/04: Bump properties for the next version
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit ec0845e5e053bfa562e7b6f43d34434aa731e688
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 20 10:50:27 2025 -0400
Bump properties for the next version
---
pom.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index e77dd7ab..6f2f38a3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<version>84</version>
</parent>
<artifactId>commons-text</artifactId>
- <version>1.13.2-SNAPSHOT</version>
+ <version>1.14.0-SNAPSHOT</version>
<name>Apache Commons Text</name>
<description>Apache Commons Text is a set of utility functions and reusable components for processing
and manipulating text in a Java environment.
@@ -41,8 +41,8 @@
<commons.packageId>text</commons.packageId>
<commons.module.name>org.apache.commons.text</commons.module.name>
- <commons.release.version>1.13.1</commons.release.version>
- <commons.release.next>1.13.2</commons.release.next>
+ <commons.release.version>1.14.0</commons.release.version>
+ <commons.release.next>1.14.1</commons.release.next>
<commons.release.desc>(Java 8+)</commons.release.desc>
<commons.jira.id>TEXT</commons.jira.id>
@@ -68,7 +68,7 @@
<!-- Commons Release Plugin -->
<!-- Previous version of the component (used for reporting binary compatibility check)-->
- <commons.bc.version>1.13.0</commons.bc.version>
+ <commons.bc.version>1.13.1</commons.bc.version>
<commons.rc.version>RC1</commons.rc.version>
<commons.release.isDistModule>true</commons.release.isDistModule>
<commons.distSvnStagingUrl>scm:svn:https://dist.apache.org/repos/dist/dev/commons/${commons.componentid}</commons.distSvnStagingUrl>
Re: (commons-text) 03/04: Interface TextRandomProvider extends IntUnaryOperator
Posted by Gary Gregory <ga...@gmail.com>.
On Tue, May 20, 2025 at 11:48 AM Alex Herbert <al...@gmail.com>
wrote:
> This change breaks the code example on how to use the class, see below:
>
> On Tue, 20 May 2025 at 15:51, <gg...@apache.org> wrote:
>
> > This is an automated email from the ASF dual-hosted git repository.
> >
> > ggregory pushed a commit to branch master
> > in repository https://gitbox.apache.org/repos/asf/commons-text.git
> >
> > commit 98aae9ada74f51b52dbcf41c7ad46452721a6ffe
> > Author: Gary Gregory <ga...@gmail.com>
> > AuthorDate: Tue May 20 10:49:31 2025 -0400
> >
> > Interface TextRandomProvider extends IntUnaryOperator
> > ---
> > src/changes/changes.xml | 1 +
> > .../apache/commons/text/RandomStringGenerator.java | 4 +--
> > .../apache/commons/text/TextRandomProvider.java | 34
> > +++++++++++++++++-----
> > 3 files changed, 29 insertions(+), 10 deletions(-)
> >
> > diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> > index b5824ded..69c3ce3f 100644
> > --- a/src/changes/changes.xml
> > +++ b/src/changes/changes.xml
> > @@ -49,6 +49,7 @@ The <action> type attribute can be
> add,update,fix,remove.
> > <!-- FIX -->
> > <!-- ADD -->
> > <action type="add" dev="ggregory" due-to="Gary Gregory">Interface
> > StringLookup now extends UnaryOperator<String>.</action>
> > + <action type="add" dev="ggregory" due-to="Gary Gregory">Interface
> > TextRandomProvider extends IntUnaryOperator.</action>
> > <!-- UPDATE -->
> > <action type="update" dev="ggregory" due-to="Dependabot, Gary
> > Gregory">Bump org.apache.commons:commons-parent from 81 to 84
> #668.</action>
> > <action type="update" dev="ggregory" due-to="Gary Gregory">Bump
> > commons-io:commons-io from 2.18.0 to 2.19.0.</action>
> > diff --git
> > a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> > b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> > index df3f3938..4a999649 100644
> > --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> > +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> > @@ -459,7 +459,7 @@ public final class RandomStringGenerator {
> > */
> > private int generateRandomNumber(final int minInclusive, final int
> > maxInclusive) {
> > if (random != null) {
> > - return random.nextInt(maxInclusive - minInclusive + 1) +
> > minInclusive;
> > + return random.applyAsInt(maxInclusive - minInclusive + 1) +
> > minInclusive;
> > }
> > return ThreadLocalRandom.current().nextInt(minInclusive,
> > maxInclusive + 1);
> > }
> > @@ -474,7 +474,7 @@ public final class RandomStringGenerator {
> > private int generateRandomNumber(final List<Character>
> characterList)
> > {
> > final int listSize = characterList.size();
> > if (random != null) {
> > - return
> >
> String.valueOf(characterList.get(random.nextInt(listSize))).codePointAt(0);
> > + return
> >
> String.valueOf(characterList.get(random.applyAsInt(listSize))).codePointAt(0);
> > }
> > return
> > String.valueOf(characterList.get(ThreadLocalRandom.current().nextInt(0,
> > listSize))).codePointAt(0);
> > }
> > diff --git
> a/src/main/java/org/apache/commons/text/TextRandomProvider.java
> > b/src/main/java/org/apache/commons/text/TextRandomProvider.java
> > index 0190d9cb..23ba9173 100644
> > --- a/src/main/java/org/apache/commons/text/TextRandomProvider.java
> > +++ b/src/main/java/org/apache/commons/text/TextRandomProvider.java
> > @@ -16,6 +16,8 @@
> > */
> > package org.apache.commons.text;
> >
> > +import java.util.function.IntUnaryOperator;
> > +
> > /**
> > * TextRandomProvider implementations are used by {@link
> > RandomStringGenerator}
> > * as a source of randomness. It is highly recommended that the
> > @@ -23,27 +25,43 @@ package org.apache.commons.text;
> > * library be used to provide the random number generation.
> > *
> > * <p>
> > - * When using Java 8 or later, TextRandomProvider is a functional
> > interface and
> > - * need not be explicitly implemented. For example:
> > + * {@code TextRandomProvider} is a functional interface and need not be
> > explicitly implemented.
> > + * </p>
> > + * <p>
> > + * For example:
> > * </p>
> > * <pre>
> > * {@code
> > * UniformRandomProvider rng = RandomSource.create(...);
> > * RandomStringGenerator gen = RandomStringGenerator.builder()
> > - * .usingRandom(rng::nextInt)
> > + * .usingRandom(rng::applyAsInt)
> >
>
> This is not a valid example. The UniformRandomProvider interface does not
> have a 'applyAsInt' method, so the code would not compile.
>
I fixed the Javadoc in git master. TY!
Gary
>
>
>
> > * // additional builder calls as needed
> > * .build();
> > * }
> > * </pre>
> > * @since 1.1
> > */
> > -public interface TextRandomProvider {
> > +public interface TextRandomProvider extends IntUnaryOperator {
> > +
> > + /**
> > + * Generates an int value between 0 (inclusive) and the specified
> > value (exclusive).
> > + *
> > + * @param max Bound on the random number to be returned. Must be
> > positive.
> > + * @return a random int value between 0 (inclusive) and max
> > (exclusive).
> > + * @since 1.14.0
> > + */
> > + @Override
> > + default int applyAsInt(final int max) {
> > + return nextInt(max);
> > + }
> >
> > /**
> > - * Generates an int value between 0 (inclusive) and the specified
> > value
> > - * (exclusive).
> > - * @param max Bound on the random number to be returned. Must be
> > positive.
> > - * @return a random int value between 0 (inclusive) and n
> (exclusive).
> > + * Generates an int value between 0 (inclusive) and the specified
> > value (exclusive).
> > + *
> > + * @param max Bound on the random number to be returned. Must be
> > positive.
> > + * @return a random int value between 0 (inclusive) and max
> > (exclusive).
> > + * @deprecated Use {@link #applyAsInt(int)}.
> > */
> > + @Deprecated
> > int nextInt(int max);
> > }
> >
> >
>
Re: (commons-text) 03/04: Interface TextRandomProvider extends IntUnaryOperator
Posted by Alex Herbert <al...@gmail.com>.
This change breaks the code example on how to use the class, see below:
On Tue, 20 May 2025 at 15:51, <gg...@apache.org> wrote:
> This is an automated email from the ASF dual-hosted git repository.
>
> ggregory pushed a commit to branch master
> in repository https://gitbox.apache.org/repos/asf/commons-text.git
>
> commit 98aae9ada74f51b52dbcf41c7ad46452721a6ffe
> Author: Gary Gregory <ga...@gmail.com>
> AuthorDate: Tue May 20 10:49:31 2025 -0400
>
> Interface TextRandomProvider extends IntUnaryOperator
> ---
> src/changes/changes.xml | 1 +
> .../apache/commons/text/RandomStringGenerator.java | 4 +--
> .../apache/commons/text/TextRandomProvider.java | 34
> +++++++++++++++++-----
> 3 files changed, 29 insertions(+), 10 deletions(-)
>
> diff --git a/src/changes/changes.xml b/src/changes/changes.xml
> index b5824ded..69c3ce3f 100644
> --- a/src/changes/changes.xml
> +++ b/src/changes/changes.xml
> @@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
> <!-- FIX -->
> <!-- ADD -->
> <action type="add" dev="ggregory" due-to="Gary Gregory">Interface
> StringLookup now extends UnaryOperator<String>.</action>
> + <action type="add" dev="ggregory" due-to="Gary Gregory">Interface
> TextRandomProvider extends IntUnaryOperator.</action>
> <!-- UPDATE -->
> <action type="update" dev="ggregory" due-to="Dependabot, Gary
> Gregory">Bump org.apache.commons:commons-parent from 81 to 84 #668.</action>
> <action type="update" dev="ggregory" due-to="Gary Gregory">Bump
> commons-io:commons-io from 2.18.0 to 2.19.0.</action>
> diff --git
> a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> index df3f3938..4a999649 100644
> --- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> +++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
> @@ -459,7 +459,7 @@ public final class RandomStringGenerator {
> */
> private int generateRandomNumber(final int minInclusive, final int
> maxInclusive) {
> if (random != null) {
> - return random.nextInt(maxInclusive - minInclusive + 1) +
> minInclusive;
> + return random.applyAsInt(maxInclusive - minInclusive + 1) +
> minInclusive;
> }
> return ThreadLocalRandom.current().nextInt(minInclusive,
> maxInclusive + 1);
> }
> @@ -474,7 +474,7 @@ public final class RandomStringGenerator {
> private int generateRandomNumber(final List<Character> characterList)
> {
> final int listSize = characterList.size();
> if (random != null) {
> - return
> String.valueOf(characterList.get(random.nextInt(listSize))).codePointAt(0);
> + return
> String.valueOf(characterList.get(random.applyAsInt(listSize))).codePointAt(0);
> }
> return
> String.valueOf(characterList.get(ThreadLocalRandom.current().nextInt(0,
> listSize))).codePointAt(0);
> }
> diff --git a/src/main/java/org/apache/commons/text/TextRandomProvider.java
> b/src/main/java/org/apache/commons/text/TextRandomProvider.java
> index 0190d9cb..23ba9173 100644
> --- a/src/main/java/org/apache/commons/text/TextRandomProvider.java
> +++ b/src/main/java/org/apache/commons/text/TextRandomProvider.java
> @@ -16,6 +16,8 @@
> */
> package org.apache.commons.text;
>
> +import java.util.function.IntUnaryOperator;
> +
> /**
> * TextRandomProvider implementations are used by {@link
> RandomStringGenerator}
> * as a source of randomness. It is highly recommended that the
> @@ -23,27 +25,43 @@ package org.apache.commons.text;
> * library be used to provide the random number generation.
> *
> * <p>
> - * When using Java 8 or later, TextRandomProvider is a functional
> interface and
> - * need not be explicitly implemented. For example:
> + * {@code TextRandomProvider} is a functional interface and need not be
> explicitly implemented.
> + * </p>
> + * <p>
> + * For example:
> * </p>
> * <pre>
> * {@code
> * UniformRandomProvider rng = RandomSource.create(...);
> * RandomStringGenerator gen = RandomStringGenerator.builder()
> - * .usingRandom(rng::nextInt)
> + * .usingRandom(rng::applyAsInt)
>
This is not a valid example. The UniformRandomProvider interface does not
have a 'applyAsInt' method, so the code would not compile.
> * // additional builder calls as needed
> * .build();
> * }
> * </pre>
> * @since 1.1
> */
> -public interface TextRandomProvider {
> +public interface TextRandomProvider extends IntUnaryOperator {
> +
> + /**
> + * Generates an int value between 0 (inclusive) and the specified
> value (exclusive).
> + *
> + * @param max Bound on the random number to be returned. Must be
> positive.
> + * @return a random int value between 0 (inclusive) and max
> (exclusive).
> + * @since 1.14.0
> + */
> + @Override
> + default int applyAsInt(final int max) {
> + return nextInt(max);
> + }
>
> /**
> - * Generates an int value between 0 (inclusive) and the specified
> value
> - * (exclusive).
> - * @param max Bound on the random number to be returned. Must be
> positive.
> - * @return a random int value between 0 (inclusive) and n (exclusive).
> + * Generates an int value between 0 (inclusive) and the specified
> value (exclusive).
> + *
> + * @param max Bound on the random number to be returned. Must be
> positive.
> + * @return a random int value between 0 (inclusive) and max
> (exclusive).
> + * @deprecated Use {@link #applyAsInt(int)}.
> */
> + @Deprecated
> int nextInt(int max);
> }
>
>
(commons-text) 03/04: Interface TextRandomProvider extends IntUnaryOperator
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit 98aae9ada74f51b52dbcf41c7ad46452721a6ffe
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 20 10:49:31 2025 -0400
Interface TextRandomProvider extends IntUnaryOperator
---
src/changes/changes.xml | 1 +
.../apache/commons/text/RandomStringGenerator.java | 4 +--
.../apache/commons/text/TextRandomProvider.java | 34 +++++++++++++++++-----
3 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index b5824ded..69c3ce3f 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -49,6 +49,7 @@ The <action> type attribute can be add,update,fix,remove.
<!-- FIX -->
<!-- ADD -->
<action type="add" dev="ggregory" due-to="Gary Gregory">Interface StringLookup now extends UnaryOperator<String>.</action>
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Interface TextRandomProvider extends IntUnaryOperator.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 81 to 84 #668.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.18.0 to 2.19.0.</action>
diff --git a/src/main/java/org/apache/commons/text/RandomStringGenerator.java b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
index df3f3938..4a999649 100644
--- a/src/main/java/org/apache/commons/text/RandomStringGenerator.java
+++ b/src/main/java/org/apache/commons/text/RandomStringGenerator.java
@@ -459,7 +459,7 @@ public final class RandomStringGenerator {
*/
private int generateRandomNumber(final int minInclusive, final int maxInclusive) {
if (random != null) {
- return random.nextInt(maxInclusive - minInclusive + 1) + minInclusive;
+ return random.applyAsInt(maxInclusive - minInclusive + 1) + minInclusive;
}
return ThreadLocalRandom.current().nextInt(minInclusive, maxInclusive + 1);
}
@@ -474,7 +474,7 @@ public final class RandomStringGenerator {
private int generateRandomNumber(final List<Character> characterList) {
final int listSize = characterList.size();
if (random != null) {
- return String.valueOf(characterList.get(random.nextInt(listSize))).codePointAt(0);
+ return String.valueOf(characterList.get(random.applyAsInt(listSize))).codePointAt(0);
}
return String.valueOf(characterList.get(ThreadLocalRandom.current().nextInt(0, listSize))).codePointAt(0);
}
diff --git a/src/main/java/org/apache/commons/text/TextRandomProvider.java b/src/main/java/org/apache/commons/text/TextRandomProvider.java
index 0190d9cb..23ba9173 100644
--- a/src/main/java/org/apache/commons/text/TextRandomProvider.java
+++ b/src/main/java/org/apache/commons/text/TextRandomProvider.java
@@ -16,6 +16,8 @@
*/
package org.apache.commons.text;
+import java.util.function.IntUnaryOperator;
+
/**
* TextRandomProvider implementations are used by {@link RandomStringGenerator}
* as a source of randomness. It is highly recommended that the
@@ -23,27 +25,43 @@ package org.apache.commons.text;
* library be used to provide the random number generation.
*
* <p>
- * When using Java 8 or later, TextRandomProvider is a functional interface and
- * need not be explicitly implemented. For example:
+ * {@code TextRandomProvider} is a functional interface and need not be explicitly implemented.
+ * </p>
+ * <p>
+ * For example:
* </p>
* <pre>
* {@code
* UniformRandomProvider rng = RandomSource.create(...);
* RandomStringGenerator gen = RandomStringGenerator.builder()
- * .usingRandom(rng::nextInt)
+ * .usingRandom(rng::applyAsInt)
* // additional builder calls as needed
* .build();
* }
* </pre>
* @since 1.1
*/
-public interface TextRandomProvider {
+public interface TextRandomProvider extends IntUnaryOperator {
+
+ /**
+ * Generates an int value between 0 (inclusive) and the specified value (exclusive).
+ *
+ * @param max Bound on the random number to be returned. Must be positive.
+ * @return a random int value between 0 (inclusive) and max (exclusive).
+ * @since 1.14.0
+ */
+ @Override
+ default int applyAsInt(final int max) {
+ return nextInt(max);
+ }
/**
- * Generates an int value between 0 (inclusive) and the specified value
- * (exclusive).
- * @param max Bound on the random number to be returned. Must be positive.
- * @return a random int value between 0 (inclusive) and n (exclusive).
+ * Generates an int value between 0 (inclusive) and the specified value (exclusive).
+ *
+ * @param max Bound on the random number to be returned. Must be positive.
+ * @return a random int value between 0 (inclusive) and max (exclusive).
+ * @deprecated Use {@link #applyAsInt(int)}.
*/
+ @Deprecated
int nextInt(int max);
}
(commons-text) 01/04: Interface StringLookup now extends UnaryOperator
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit 70cecfbc3efc1358bc89c05a2bf79361ed234be4
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 20 10:40:01 2025 -0400
Interface StringLookup now extends UnaryOperator<String>
---
src/changes/changes.xml | 3 +-
.../org/apache/commons/text/StrSubstitutor.java | 2 +-
.../org/apache/commons/text/StringSubstitutor.java | 2 +-
.../apache/commons/text/lookup/BiStringLookup.java | 2 +-
.../text/lookup/InterpolatorStringLookup.java | 4 +-
.../text/lookup/JavaPlatformStringLookup.java | 2 +-
.../apache/commons/text/lookup/StringLookup.java | 37 ++++++++++++++++-
.../org/apache/commons/text/StrLookupTest.java | 48 +++++++++++-----------
.../apache/commons/text/StringSubstitutorTest.java | 1 +
...ubstitutorWithInterpolatorStringLookupTest.java | 1 +
.../text/lookup/Base64DecoderStringLookupTest.java | 4 +-
.../text/lookup/Base64EncoderStringLookupTest.java | 4 +-
.../text/lookup/BiFunctionStringLookupTest.java | 8 ++--
.../text/lookup/ConstantStringLookupBasicTest.java | 8 ++--
.../text/lookup/ConstantStringLookupTest.java | 16 ++++----
.../commons/text/lookup/DateStringLookupTest.java | 6 +--
.../commons/text/lookup/DnsStringLookupTest.java | 12 +++---
.../EnvironmentVariableStringLookupTest.java | 6 +--
.../commons/text/lookup/FileStringLookupTest.java | 26 ++++++------
.../text/lookup/FunctionStringLookupTest.java | 8 ++--
.../InetAddressStringLookupLocalHostTest.java | 10 ++---
...InetAddressStringLookupLoopbackAddressTest.java | 10 ++---
.../text/lookup/InterpolatorStringLookupTest.java | 20 ++++-----
.../text/lookup/JavaPlatformStringLookupTest.java | 6 +--
.../commons/text/lookup/NullStringLookupTest.java | 4 +-
.../text/lookup/PropertiesStringLookupTest.java | 34 +++++++--------
.../lookup/ResourceBundleStringLookupTest.java | 18 ++++----
.../text/lookup/ScriptStringLookupTest.java | 14 +++----
.../lookup/SystemPropertyStringLookupTest.java | 4 +-
.../text/lookup/UrlDecoderStringLookupTest.java | 10 ++---
.../text/lookup/UrlEncoderStringLookupTest.java | 6 +--
.../commons/text/lookup/UrlStringLookupTest.java | 16 ++++----
.../text/lookup/XmlDecoderStringLookupTest.java | 4 +-
.../text/lookup/XmlEncoderStringLookupTest.java | 4 +-
.../commons/text/lookup/XmlStringLookupTest.java | 24 +++++------
35 files changed, 211 insertions(+), 173 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 01aa612c..b5824ded 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,9 +45,10 @@ The <action> type attribute can be add,update,fix,remove.
<title>Apache Commons Text Changes</title>
</properties>
<body>
- <release version="1.13.2" date="YYYY-MM-DD" description="Release 1.13.2. Requires Java 8 or above.">
+ <release version="1.14.0" date="YYYY-MM-DD" description="Release 1.13.2. Requires Java 8 or above.">
<!-- FIX -->
<!-- ADD -->
+ <action type="add" dev="ggregory" due-to="Gary Gregory">Interface StringLookup now extends UnaryOperator<String>.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump org.apache.commons:commons-parent from 81 to 84 #668.</action>
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump commons-io:commons-io from 2.18.0 to 2.19.0.</action>
diff --git a/src/main/java/org/apache/commons/text/StrSubstitutor.java b/src/main/java/org/apache/commons/text/StrSubstitutor.java
index 085751dc..a0b86f98 100644
--- a/src/main/java/org/apache/commons/text/StrSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StrSubstitutor.java
@@ -874,7 +874,7 @@ public class StrSubstitutor {
if (resolver == null) {
return null;
}
- return resolver.lookup(variableName);
+ return resolver.apply(variableName);
}
/**
diff --git a/src/main/java/org/apache/commons/text/StringSubstitutor.java b/src/main/java/org/apache/commons/text/StringSubstitutor.java
index f092bd25..6570dbd4 100644
--- a/src/main/java/org/apache/commons/text/StringSubstitutor.java
+++ b/src/main/java/org/apache/commons/text/StringSubstitutor.java
@@ -1152,7 +1152,7 @@ public class StringSubstitutor {
if (resolver == null) {
return null;
}
- return resolver.lookup(variableName);
+ return resolver.apply(variableName);
}
/**
diff --git a/src/main/java/org/apache/commons/text/lookup/BiStringLookup.java b/src/main/java/org/apache/commons/text/lookup/BiStringLookup.java
index 33cdd4a8..f18cc686 100644
--- a/src/main/java/org/apache/commons/text/lookup/BiStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/BiStringLookup.java
@@ -68,7 +68,7 @@ public interface BiStringLookup<U> extends StringLookup {
* @return The matching value, null if no match.
*/
default String lookup(final String key, final U object) {
- return lookup(key);
+ return apply(key);
}
}
diff --git a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
index 0fa7b780..66a3ea26 100644
--- a/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/InterpolatorStringLookup.java
@@ -124,7 +124,7 @@ final class InterpolatorStringLookup extends AbstractStringLookup {
final StringLookup lookup = stringLookupMap.get(prefix);
String value = null;
if (lookup != null) {
- value = lookup.lookup(name);
+ value = lookup.apply(name);
}
if (value != null) {
@@ -133,7 +133,7 @@ final class InterpolatorStringLookup extends AbstractStringLookup {
key = key.substring(prefixPos + 1);
}
if (defaultStringLookup != null) {
- return defaultStringLookup.lookup(key);
+ return defaultStringLookup.apply(key);
}
return null;
}
diff --git a/src/main/java/org/apache/commons/text/lookup/JavaPlatformStringLookup.java b/src/main/java/org/apache/commons/text/lookup/JavaPlatformStringLookup.java
index 0e21330d..6b0821ba 100644
--- a/src/main/java/org/apache/commons/text/lookup/JavaPlatformStringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/JavaPlatformStringLookup.java
@@ -146,7 +146,7 @@ final class JavaPlatformStringLookup extends AbstractStringLookup {
* @return a system property value.
*/
private String getSystemProperty(final String name) {
- return StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.lookup(name);
+ return StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.apply(name);
}
/**
diff --git a/src/main/java/org/apache/commons/text/lookup/StringLookup.java b/src/main/java/org/apache/commons/text/lookup/StringLookup.java
index d80a7bfb..b59bbc0a 100644
--- a/src/main/java/org/apache/commons/text/lookup/StringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/StringLookup.java
@@ -17,6 +17,8 @@
package org.apache.commons.text.lookup;
+import java.util.function.UnaryOperator;
+
/**
* Lookups a String key for a String value.
* <p>
@@ -31,7 +33,38 @@ package org.apache.commons.text.lookup;
* @since 1.3
*/
@FunctionalInterface
-public interface StringLookup {
+public interface StringLookup extends UnaryOperator<String> {
+
+ /**
+ * Looks up a String key to provide a String value.
+ * <p>
+ * The internal implementation may use any mechanism to return the value. The simplest implementation is to use a
+ * Map. However, virtually any implementation is possible.
+ * </p>
+ * <p>
+ * For example, it would be possible to implement a lookup that used the key as a primary key, and looked up the
+ * value on demand from the database Or, a numeric based implementation could be created that treats the key as an
+ * integer, increments the value and return the result as a string - converting 1 to 2, 15 to 16 etc.
+ * </p>
+ * <p>
+ * This method always returns a String, regardless of the underlying data, by converting it as necessary. For
+ * example:
+ * </p>
+ *
+ * <pre>
+ * Map<String, Object> map = new HashMap<String, Object>();
+ * map.put("number", Integer.valueOf(2));
+ * assertEquals("2", StringLookupFactory.mapStringLookup(map).lookup("number"));
+ * </pre>
+ *
+ * @param key the key to look up, may be null.
+ * @return The matching value, null if no match.
+ * @since 1.14.0
+ */
+ @Override
+ default String apply(String key) {
+ return lookup(key);
+ }
/**
* Looks up a String key to provide a String value.
@@ -57,6 +90,8 @@ public interface StringLookup {
*
* @param key the key to look up, may be null.
* @return The matching value, null if no match.
+ * @deprecated Use {@link #apply(String)}.
*/
+ @Deprecated
String lookup(String key);
}
diff --git a/src/test/java/org/apache/commons/text/StrLookupTest.java b/src/test/java/org/apache/commons/text/StrLookupTest.java
index 082d3a8d..ff148fbd 100644
--- a/src/test/java/org/apache/commons/text/StrLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StrLookupTest.java
@@ -40,52 +40,52 @@ public class StrLookupTest {
final Map<String, Object> map = new HashMap<>();
map.put("key", "value");
map.put("number", 2);
- assertEquals("value", StrLookup.mapLookup(map).lookup("key"));
- assertEquals("2", StrLookup.mapLookup(map).lookup("number"));
- assertNull(StrLookup.mapLookup(map).lookup(null));
- assertNull(StrLookup.mapLookup(map).lookup(""));
- assertNull(StrLookup.mapLookup(map).lookup("other"));
+ assertEquals("value", StrLookup.mapLookup(map).apply("key"));
+ assertEquals("2", StrLookup.mapLookup(map).apply("number"));
+ assertNull(StrLookup.mapLookup(map).apply(null));
+ assertNull(StrLookup.mapLookup(map).apply(""));
+ assertNull(StrLookup.mapLookup(map).apply("other"));
}
@Test
public void testMapLookup_nullMap() {
final Map<String, ?> map = null;
- assertNull(StrLookup.mapLookup(map).lookup(null));
- assertNull(StrLookup.mapLookup(map).lookup(""));
- assertNull(StrLookup.mapLookup(map).lookup("any"));
+ assertNull(StrLookup.mapLookup(map).apply(null));
+ assertNull(StrLookup.mapLookup(map).apply(""));
+ assertNull(StrLookup.mapLookup(map).apply("any"));
}
@Test
public void testNoneLookup() {
- assertNull(StrLookup.noneLookup().lookup(null));
- assertNull(StrLookup.noneLookup().lookup(""));
- assertNull(StrLookup.noneLookup().lookup("any"));
+ assertNull(StrLookup.noneLookup().apply(null));
+ assertNull(StrLookup.noneLookup().apply(""));
+ assertNull(StrLookup.noneLookup().apply("any"));
}
@Test
public void testResourceBundleLookup() {
final ResourceBundle map = ResourceBundle.getBundle("org.apache.commons.text.example.testResourceBundleLookup");
- assertEquals("value", StrLookup.resourceBundleLookup(map).lookup("key"));
+ assertEquals("value", StrLookup.resourceBundleLookup(map).apply("key"));
assertEquals("2", StrLookup.resourceBundleLookup(map).lookup("number"));
- assertNull(StrLookup.resourceBundleLookup(map).lookup(null));
- assertNull(StrLookup.resourceBundleLookup(map).lookup(""));
- assertNull(StrLookup.resourceBundleLookup(map).lookup("other"));
+ assertNull(StrLookup.resourceBundleLookup(map).apply(null));
+ assertNull(StrLookup.resourceBundleLookup(map).apply(""));
+ assertNull(StrLookup.resourceBundleLookup(map).apply("other"));
}
@Test
public void testResourceBundleLookup_nullMap() {
final ResourceBundle resourceBundle = null;
- assertNull(StrLookup.resourceBundleLookup(resourceBundle).lookup(null));
- assertNull(StrLookup.resourceBundleLookup(resourceBundle).lookup(""));
- assertNull(StrLookup.resourceBundleLookup(resourceBundle).lookup("any"));
+ assertNull(StrLookup.resourceBundleLookup(resourceBundle).apply(null));
+ assertNull(StrLookup.resourceBundleLookup(resourceBundle).apply(""));
+ assertNull(StrLookup.resourceBundleLookup(resourceBundle).apply("any"));
}
@Test
public void testSystemPropertiesLookup() {
- assertEquals(System.getProperty("os.name"), StrLookup.systemPropertiesLookup().lookup("os.name"));
- assertNull(StrLookup.systemPropertiesLookup().lookup(""));
- assertNull(StrLookup.systemPropertiesLookup().lookup("other"));
- assertThrows(NullPointerException.class, () -> StrLookup.systemPropertiesLookup().lookup(null));
+ assertEquals(System.getProperty("os.name"), StrLookup.systemPropertiesLookup().apply("os.name"));
+ assertNull(StrLookup.systemPropertiesLookup().apply(""));
+ assertNull(StrLookup.systemPropertiesLookup().apply("other"));
+ assertThrows(NullPointerException.class, () -> StrLookup.systemPropertiesLookup().apply(null));
}
/**
@@ -104,7 +104,7 @@ public class StrLookupTest {
newProps.setProperty(osName, newOsName);
System.setProperties(newProps);
try {
- assertEquals(newOsName, sysLookup.lookup(osName), "Changed properties not detected");
+ assertEquals(newOsName, sysLookup.apply(osName), "Changed properties not detected");
} finally {
System.setProperties(oldProperties);
}
@@ -123,7 +123,7 @@ public class StrLookupTest {
final StrLookup<String> sysLookup = StrLookup.systemPropertiesLookup();
System.setProperty(osName, newOsName);
try {
- assertEquals(newOsName, sysLookup.lookup(osName), "Changed properties not detected");
+ assertEquals(newOsName, sysLookup.apply(osName), "Changed properties not detected");
} finally {
System.setProperty(osName, oldOs);
}
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
index 97b18dde..3d25f27e 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorTest.java
@@ -201,6 +201,7 @@ public class StringSubstitutorTest {
public void testConstructorNullMap() {
final Map<String, Object> parameters = null;
final StringSubstitutor s = new StringSubstitutor(parameters, "prefix", "suffix");
+ assertNull(s.getStringLookup().apply("X"));
assertNull(s.getStringLookup().lookup("X"));
}
diff --git a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
index f9ccc623..bcae095f 100644
--- a/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/StringSubstitutorWithInterpolatorStringLookupTest.java
@@ -130,6 +130,7 @@ public class StringSubstitutorWithInterpolatorStringLookupTest {
public void testDefaultValueForMissingKeyInResourceBundle() {
final StringLookup interpolatorStringLookup = StringLookupFactory.INSTANCE.interpolatorStringLookup(
StringLookupFactory.INSTANCE.resourceBundleStringLookup("org.apache.commons.text.example.testResourceBundleLookup"));
+ assertEquals("${missingKey:-defaultValue}", interpolatorStringLookup.apply("keyWithMissingKey"));
assertEquals("${missingKey:-defaultValue}", interpolatorStringLookup.lookup("keyWithMissingKey"));
final StringSubstitutor stringSubstitutor = new StringSubstitutor(interpolatorStringLookup);
// The following would throw a MissingResourceException before TEXT-165.
diff --git a/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
index bf8c40fc..e51df98c 100644
--- a/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/Base64DecoderStringLookupTest.java
@@ -27,12 +27,12 @@ public class Base64DecoderStringLookupTest {
@Test
public void test() {
- Assertions.assertEquals("HelloWorld!", StringLookupFactory.INSTANCE_BASE64_DECODER.lookup("SGVsbG9Xb3JsZCE="));
+ Assertions.assertEquals("HelloWorld!", StringLookupFactory.INSTANCE_BASE64_DECODER.apply("SGVsbG9Xb3JsZCE="));
}
@Test
public void testNull() {
- Assertions.assertNull(StringLookupFactory.INSTANCE_BASE64_DECODER.lookup(null));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_BASE64_DECODER.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
index b31e9b9d..80acd9c0 100644
--- a/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/Base64EncoderStringLookupTest.java
@@ -27,12 +27,12 @@ public class Base64EncoderStringLookupTest {
@Test
public void test() {
- Assertions.assertEquals("SGVsbG9Xb3JsZCE=", StringLookupFactory.INSTANCE_BASE64_ENCODER.lookup("HelloWorld!"));
+ Assertions.assertEquals("SGVsbG9Xb3JsZCE=", StringLookupFactory.INSTANCE_BASE64_ENCODER.apply("HelloWorld!"));
}
@Test
public void testNull() {
- Assertions.assertNull(StringLookupFactory.INSTANCE_BASE64_ENCODER.lookup(null));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_BASE64_ENCODER.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
index 85e07413..26485b42 100644
--- a/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/BiFunctionStringLookupTest.java
@@ -79,17 +79,17 @@ public class BiFunctionStringLookupTest {
@Test
public void testConcurrentHashMapNull() {
- Assertions.assertNull(BiFunctionStringLookup.on(new ConcurrentHashMap<>()).lookup(null));
+ Assertions.assertNull(BiFunctionStringLookup.on(new ConcurrentHashMap<>()).apply(null));
}
@Test
public void testHashMapNull() {
- Assertions.assertNull(BiFunctionStringLookup.on(new HashMap<>()).lookup(null));
+ Assertions.assertNull(BiFunctionStringLookup.on(new HashMap<>()).apply(null));
}
@Test
public void testNullBiFunction() {
- Assertions.assertNull(BiFunctionStringLookup.on((BiFunction<String, Object, Object>) null).lookup(null));
+ Assertions.assertNull(BiFunctionStringLookup.on((BiFunction<String, Object, Object>) null).apply(null));
}
@Test
@@ -98,7 +98,7 @@ public class BiFunctionStringLookupTest {
final String value = "value";
final Map<String, String> map = new HashMap<>();
map.put(key, value);
- Assertions.assertEquals(value, FunctionStringLookup.on(map).lookup(key));
+ Assertions.assertEquals(value, FunctionStringLookup.on(map).apply(key));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupBasicTest.java b/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupBasicTest.java
index ce40d727..a1de95f1 100644
--- a/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupBasicTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupBasicTest.java
@@ -55,7 +55,7 @@ public class ConstantStringLookupBasicTest {
@Test
public void testNull() {
- Assertions.assertNull(ConstantStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(ConstantStringLookup.INSTANCE.apply(null));
}
@Test
@@ -65,19 +65,19 @@ public class ConstantStringLookupBasicTest {
protected Class<?> fetchClass(final String className) throws ClassNotFoundException {
return null;
}
- }.lookup(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
+ }.apply(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
}
@Test
public void testNullValue() {
Assertions.assertEquals(NULL_STRING_FIXTURE, ConstantStringLookup.INSTANCE
- .lookup(ConstantStringLookupBasicTest.class.getName() + ".NULL_STRING_FIXTURE"));
+ .apply(ConstantStringLookupBasicTest.class.getName() + ".NULL_STRING_FIXTURE"));
}
@Test
public void testOne() {
Assertions.assertEquals(STRING_FIXTURE,
- ConstantStringLookup.INSTANCE.lookup(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
+ ConstantStringLookup.INSTANCE.apply(ConstantStringLookupBasicTest.class.getName() + ".STRING_FIXTURE"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupTest.java
index aa259462..137fccd7 100644
--- a/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ConstantStringLookupTest.java
@@ -71,7 +71,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupConstant() {
- Assertions.assertEquals(FIELD, stringLookup.lookup(variable("FIELD")), "Wrong value of constant");
+ Assertions.assertEquals(FIELD, stringLookup.apply(variable("FIELD")), "Wrong value of constant");
}
/**
@@ -79,7 +79,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupInvalidSyntax() {
- Assertions.assertNull(stringLookup.lookup("InvalidVariableName"),
+ Assertions.assertNull(stringLookup.apply("InvalidVariableName"),
"Non null return value for invalid variable name");
}
@@ -88,7 +88,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupNonExisting() {
- Assertions.assertNull(stringLookup.lookup(variable("NO_FIELD")),
+ Assertions.assertNull(stringLookup.apply(variable("NO_FIELD")),
"Non null return value for non existing constant");
}
@@ -99,8 +99,8 @@ public class ConstantStringLookupTest {
public void testLookupNonString() {
final String ref = KeyEvent.class.getName() + ".VK_ESCAPE";
final String expected = Integer.toString(KeyEvent.VK_ESCAPE);
- Assertions.assertEquals(expected, stringLookup.lookup(ref), "Wrong result of first lookup");
- Assertions.assertEquals(expected, stringLookup.lookup(ref), "Wrong result of 2nd lookup");
+ Assertions.assertEquals(expected, stringLookup.apply(ref), "Wrong result of first lookup");
+ Assertions.assertEquals(expected, stringLookup.apply(ref), "Wrong result of 2nd lookup");
}
/**
@@ -108,7 +108,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupNull() {
- Assertions.assertNull(stringLookup.lookup(null), "Non null return value for null variable");
+ Assertions.assertNull(stringLookup.apply(null), "Non null return value for null variable");
}
/**
@@ -116,7 +116,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupPrivate() {
- Assertions.assertNull(stringLookup.lookup(variable("PRIVATE_FIELD")),
+ Assertions.assertNull(stringLookup.apply(variable("PRIVATE_FIELD")),
"Non null return value for non accessible field");
}
@@ -125,7 +125,7 @@ public class ConstantStringLookupTest {
*/
@Test
public void testLookupUnknownClass() {
- Assertions.assertNull(stringLookup.lookup("org.apache.commons.configuration.NonExistingConfig." + FIELD),
+ Assertions.assertNull(stringLookup.apply("org.apache.commons.configuration.NonExistingConfig." + FIELD),
"Non null return value for unknown class");
}
diff --git a/src/test/java/org/apache/commons/text/lookup/DateStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/DateStringLookupTest.java
index 6550883e..e867a1ee 100644
--- a/src/test/java/org/apache/commons/text/lookup/DateStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/DateStringLookupTest.java
@@ -37,12 +37,12 @@ public class DateStringLookupTest {
@Test
public void testBadFormat() {
assertThrows(IllegalArgumentException.class,
- () -> DateStringLookup.INSTANCE.lookup("this-is-a-bad-format-dontcha-know"));
+ () -> DateStringLookup.INSTANCE.apply("this-is-a-bad-format-dontcha-know"));
}
@Test
public void testDefault() throws ParseException {
- final String formatted = DateStringLookup.INSTANCE.lookup(null);
+ final String formatted = DateStringLookup.INSTANCE.apply(null);
DateFormat.getInstance().parse(formatted); // throws ParseException
}
@@ -50,7 +50,7 @@ public class DateStringLookupTest {
@Test
public void testFormat() {
final String format = "yyyy-MM-dd";
- final String value = DateStringLookup.INSTANCE.lookup(format);
+ final String value = DateStringLookup.INSTANCE.apply(format);
// System.out.println(value);
assertNotNull(value, "No Date");
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format);
diff --git a/src/test/java/org/apache/commons/text/lookup/DnsStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/DnsStringLookupTest.java
index f72e55df..684275e3 100644
--- a/src/test/java/org/apache/commons/text/lookup/DnsStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/DnsStringLookupTest.java
@@ -32,28 +32,28 @@ public class DnsStringLookupTest {
public void testAddressFromHostAddress() throws UnknownHostException {
final InetAddress localHost = InetAddress.getLocalHost();
Assertions.assertEquals(localHost.getHostAddress(),
- DnsStringLookup.INSTANCE.lookup("address|" + localHost.getHostAddress()));
+ DnsStringLookup.INSTANCE.apply("address|" + localHost.getHostAddress()));
}
@Test
public void testAddressFromHostName() throws UnknownHostException {
final InetAddress localHost = InetAddress.getLocalHost();
Assertions.assertEquals(localHost.getHostAddress(),
- DnsStringLookup.INSTANCE.lookup("address|" + localHost.getHostName()));
+ DnsStringLookup.INSTANCE.apply("address|" + localHost.getHostName()));
}
@Test
public void testCanonicalNameFromHostAddress() throws UnknownHostException {
final InetAddress localHost = InetAddress.getLocalHost();
Assertions.assertEquals(localHost.getCanonicalHostName(),
- DnsStringLookup.INSTANCE.lookup("canonical-name|" + localHost.getHostAddress()));
+ DnsStringLookup.INSTANCE.apply("canonical-name|" + localHost.getHostAddress()));
}
@Test
public void testCanonicalNameFromHostName() throws UnknownHostException {
final InetAddress localHost = InetAddress.getLocalHost();
Assertions.assertEquals(localHost.getCanonicalHostName(),
- DnsStringLookup.INSTANCE.lookup("canonical-name|" + localHost.getHostName()));
+ DnsStringLookup.INSTANCE.apply("canonical-name|" + localHost.getHostName()));
}
@Test
@@ -62,7 +62,7 @@ public class DnsStringLookupTest {
final InetAddress[] localHostAll = InetAddress.getAllByName(address);
boolean matched = false;
for (final InetAddress localHost : localHostAll) {
- if (localHost.getHostName().equals(DnsStringLookup.INSTANCE.lookup("name|" + address + ""))) {
+ if (localHost.getHostName().equals(DnsStringLookup.INSTANCE.apply("name|" + address + ""))) {
matched = true;
}
}
@@ -71,7 +71,7 @@ public class DnsStringLookupTest {
@Test
public void testNull() {
- Assertions.assertNull(DnsStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(DnsStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/EnvironmentVariableStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/EnvironmentVariableStringLookupTest.java
index aa5c51dc..4dc5a9e4 100644
--- a/src/test/java/org/apache/commons/text/lookup/EnvironmentVariableStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/EnvironmentVariableStringLookupTest.java
@@ -28,17 +28,17 @@ public class EnvironmentVariableStringLookupTest {
@Test
public void testNull() {
- Assertions.assertNull(StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.lookup(null));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.apply(null));
}
@Test
public void testOne() {
if (SystemUtils.IS_OS_WINDOWS) {
final String key = "PATH";
- Assertions.assertEquals(System.getenv(key), StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.lookup(key));
+ Assertions.assertEquals(System.getenv(key), StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.apply(key));
} else if (SystemUtils.IS_OS_LINUX) {
final String key = "USER";
- Assertions.assertEquals(System.getenv(key), StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.lookup(key));
+ Assertions.assertEquals(System.getenv(key), StringLookupFactory.INSTANCE_ENVIRONMENT_VARIABLES.apply(key));
}
}
diff --git a/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
index b22af473..e709b873 100644
--- a/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/FileStringLookupTest.java
@@ -44,9 +44,9 @@ public class FileStringLookupTest {
}
public static void testFence(final String expectedString, final FileStringLookup fileStringLookup) {
- Assertions.assertEquals(expectedString, fileStringLookup.lookup("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
- assertThrows(IllegalArgumentException.class, () -> fileStringLookup.lookup("UTF-8:/src/test/resources/org/apache/commons/text/document.properties"));
- assertThrows(IllegalArgumentException.class, () -> fileStringLookup.lookup("UTF-8:../src/test/resources/org/apache/commons/text/document.properties"));
+ Assertions.assertEquals(expectedString, fileStringLookup.apply("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
+ assertThrows(IllegalArgumentException.class, () -> fileStringLookup.apply("UTF-8:/src/test/resources/org/apache/commons/text/document.properties"));
+ assertThrows(IllegalArgumentException.class, () -> fileStringLookup.apply("UTF-8:../src/test/resources/org/apache/commons/text/document.properties"));
}
public static void testFence(final StringSubstitutor stringSubstitutor) throws IOException {
@@ -58,28 +58,28 @@ public class FileStringLookupTest {
@Test
public void testDefaultInstanceBadCharsetName() {
assertThrows(IllegalArgumentException.class,
- () -> FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/org/apache/commons/text/document.properties"));
+ () -> FileStringLookup.INSTANCE.apply("BAD_CHARSET_NAME:src/test/resources/org/apache/commons/text/document.properties"));
}
@Test
public void testDefaultInstanceBadDocumentPath() {
- assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:src/test/resources/DOCUMENT_NOT_FOUND.TXT"));
+ assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.apply("BAD_CHARSET_NAME:src/test/resources/DOCUMENT_NOT_FOUND.TXT"));
}
@Test
public void testDefaultInstanceMissingFilePart() {
- assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.lookup(StandardCharsets.UTF_8.name()));
+ assertThrows(IllegalArgumentException.class, () -> FileStringLookup.INSTANCE.apply(StandardCharsets.UTF_8.name()));
}
@Test
public void testDefaultInstanceNull() {
- Assertions.assertNull(FileStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(FileStringLookup.INSTANCE.apply(null));
}
@Test
public void testDefaultInstanceOne() throws Exception {
final String expectedString = readDocumentFixtureString();
- Assertions.assertEquals(expectedString, FileStringLookup.INSTANCE.lookup("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
+ Assertions.assertEquals(expectedString, FileStringLookup.INSTANCE.apply("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
}
@Test
@@ -91,9 +91,9 @@ public class FileStringLookupTest {
@Test
public void testFenceBadDirOne() throws Exception {
final FileStringLookup fileStringLookup = new FileStringLookup(Paths.get("dir does not exist at all"));
- assertThrows(IllegalArgumentException.class, () -> fileStringLookup.lookup("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
- assertThrows(IllegalArgumentException.class, () -> fileStringLookup.lookup("UTF-8:/src/test/resources/org/apache/commons/text/document.properties"));
- assertThrows(IllegalArgumentException.class, () -> fileStringLookup.lookup("UTF-8:../src/test/resources/org/apache/commons/text/document.properties"));
+ assertThrows(IllegalArgumentException.class, () -> fileStringLookup.apply("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
+ assertThrows(IllegalArgumentException.class, () -> fileStringLookup.apply("UTF-8:/src/test/resources/org/apache/commons/text/document.properties"));
+ assertThrows(IllegalArgumentException.class, () -> fileStringLookup.apply("UTF-8:../src/test/resources/org/apache/commons/text/document.properties"));
}
@Test
@@ -120,14 +120,14 @@ public class FileStringLookupTest {
@Test
public void testFenceEmptyOne() throws Exception {
final String expectedString = readDocumentFixtureString();
- Assertions.assertEquals(expectedString, new FileStringLookup().lookup("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
+ Assertions.assertEquals(expectedString, new FileStringLookup().apply("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
}
@Test
public void testFenceNullOne() throws Exception {
final String expectedString = readDocumentFixtureString();
Assertions.assertEquals(expectedString,
- new FileStringLookup((Path[]) null).lookup("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
+ new FileStringLookup((Path[]) null).apply("UTF-8:src/test/resources/org/apache/commons/text/document.properties"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/FunctionStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/FunctionStringLookupTest.java
index 1a8f75c5..cc60a728 100644
--- a/src/test/java/org/apache/commons/text/lookup/FunctionStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/FunctionStringLookupTest.java
@@ -32,17 +32,17 @@ public class FunctionStringLookupTest {
@Test
public void testConcurrentHashMapNull() {
- Assertions.assertNull(FunctionStringLookup.on(new ConcurrentHashMap<>()).lookup(null));
+ Assertions.assertNull(FunctionStringLookup.on(new ConcurrentHashMap<>()).apply(null));
}
@Test
public void testHashMapNull() {
- Assertions.assertNull(FunctionStringLookup.on(new HashMap<>()).lookup(null));
+ Assertions.assertNull(FunctionStringLookup.on(new HashMap<>()).apply(null));
}
@Test
public void testNullFunction() {
- Assertions.assertNull(FunctionStringLookup.on((Function<String, Object>) null).lookup(null));
+ Assertions.assertNull(FunctionStringLookup.on((Function<String, Object>) null).apply(null));
}
@Test
@@ -51,7 +51,7 @@ public class FunctionStringLookupTest {
final String value = "value";
final Map<String, String> map = new HashMap<>();
map.put(key, value);
- Assertions.assertEquals(value, FunctionStringLookup.on(map).lookup(key));
+ Assertions.assertEquals(value, FunctionStringLookup.on(map).apply(key));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLocalHostTest.java b/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLocalHostTest.java
index cc8e3cd5..2fd24629 100644
--- a/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLocalHostTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLocalHostTest.java
@@ -30,27 +30,27 @@ public class InetAddressStringLookupLocalHostTest {
@Test
public void testAddress() throws UnknownHostException {
- Assertions.assertEquals(InetAddress.getLocalHost().getHostAddress(), InetAddressStringLookup.LOCAL_HOST.lookup("address"));
+ Assertions.assertEquals(InetAddress.getLocalHost().getHostAddress(), InetAddressStringLookup.LOCAL_HOST.apply("address"));
}
@Test
public void testBadKey() {
- Assertions.assertThrows(IllegalArgumentException.class, () -> InetAddressStringLookup.LOCAL_HOST.lookup("FOO"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> InetAddressStringLookup.LOCAL_HOST.apply("FOO"));
}
@Test
public void testCanonicalName() throws UnknownHostException {
- Assertions.assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), InetAddressStringLookup.LOCAL_HOST.lookup("canonical-name"));
+ Assertions.assertEquals(InetAddress.getLocalHost().getCanonicalHostName(), InetAddressStringLookup.LOCAL_HOST.apply("canonical-name"));
}
@Test
public void testName() throws UnknownHostException {
- Assertions.assertEquals(InetAddress.getLocalHost().getHostName(), InetAddressStringLookup.LOCAL_HOST.lookup("name"));
+ Assertions.assertEquals(InetAddress.getLocalHost().getHostName(), InetAddressStringLookup.LOCAL_HOST.apply("name"));
}
@Test
public void testNull() {
- Assertions.assertNull(InetAddressStringLookup.LOCAL_HOST.lookup(null));
+ Assertions.assertNull(InetAddressStringLookup.LOCAL_HOST.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLoopbackAddressTest.java b/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLoopbackAddressTest.java
index 3d841440..ef6c56f9 100644
--- a/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLoopbackAddressTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/InetAddressStringLookupLoopbackAddressTest.java
@@ -29,27 +29,27 @@ public class InetAddressStringLookupLoopbackAddressTest {
@Test
public void testAddress() {
- Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostAddress(), InetAddressStringLookup.LOOPACK_ADDRESS.lookup("address"));
+ Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostAddress(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("address"));
}
@Test
public void testBadKey() {
- Assertions.assertThrows(IllegalArgumentException.class, () -> InetAddressStringLookup.LOOPACK_ADDRESS.lookup("FOO"));
+ Assertions.assertThrows(IllegalArgumentException.class, () -> InetAddressStringLookup.LOOPACK_ADDRESS.apply("FOO"));
}
@Test
public void testCanonicalName() {
- Assertions.assertEquals(InetAddress.getLoopbackAddress().getCanonicalHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.lookup("canonical-name"));
+ Assertions.assertEquals(InetAddress.getLoopbackAddress().getCanonicalHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("canonical-name"));
}
@Test
public void testName() {
- Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.lookup("name"));
+ Assertions.assertEquals(InetAddress.getLoopbackAddress().getHostName(), InetAddressStringLookup.LOOPACK_ADDRESS.apply("name"));
}
@Test
public void testNull() {
- Assertions.assertNull(InetAddressStringLookup.LOOPACK_ADDRESS.lookup(null));
+ Assertions.assertNull(InetAddressStringLookup.LOOPACK_ADDRESS.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/InterpolatorStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/InterpolatorStringLookupTest.java
index 6df8a895..882096ed 100644
--- a/src/test/java/org/apache/commons/text/lookup/InterpolatorStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/InterpolatorStringLookupTest.java
@@ -55,18 +55,18 @@ public class InterpolatorStringLookupTest {
}
private void assertLookupNotEmpty(final StringLookup lookup, final String key) {
- final String value = lookup.lookup(key);
+ final String value = lookup.apply(key);
assertNotNull(value);
assertFalse(value.isEmpty());
// System.out.println(key + " = " + value);
}
private void check(final StringLookup lookup) {
- String value = lookup.lookup("sys:" + TESTKEY);
+ String value = lookup.apply("sys:" + TESTKEY);
assertEquals(TESTVAL, value);
- value = lookup.lookup("env:PATH");
+ value = lookup.apply("env:PATH");
assertNotNull(value);
- value = lookup.lookup("date:yyyy-MM-dd");
+ value = lookup.apply("date:yyyy-MM-dd");
assertNotNull(value, "No Date");
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
final String today = format.format(new Date());
@@ -84,15 +84,15 @@ public class InterpolatorStringLookupTest {
final Map<String, String> map = new HashMap<>();
map.put(TESTKEY, TESTVAL);
final StringLookup lookup = new InterpolatorStringLookup(StringLookupFactory.INSTANCE.mapStringLookup(map));
- String value = lookup.lookup(TESTKEY);
+ String value = lookup.apply(TESTKEY);
assertEquals(TESTVAL, value);
- value = lookup.lookup("ctx:" + TESTKEY);
+ value = lookup.apply("ctx:" + TESTKEY);
assertEquals(TESTVAL, value);
- value = lookup.lookup("sys:" + TESTKEY);
+ value = lookup.apply("sys:" + TESTKEY);
assertEquals(TESTVAL, value);
- value = lookup.lookup("BadKey");
+ value = lookup.apply("BadKey");
assertNull(value);
- value = lookup.lookup("ctx:" + TESTKEY);
+ value = lookup.apply("ctx:" + TESTKEY);
assertEquals(TESTVAL, value);
}
@@ -115,7 +115,7 @@ public class InterpolatorStringLookupTest {
@Test
public void testNull() {
- Assertions.assertNull(InterpolatorStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(InterpolatorStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
index 37782afd..a38b4843 100644
--- a/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/JavaPlatformStringLookupTest.java
@@ -31,7 +31,7 @@ public class JavaPlatformStringLookupTest {
@Test
public void testBadKey() {
- assertThrows(IllegalArgumentException.class, () -> JavaPlatformStringLookup.INSTANCE.lookup("BADKEY"));
+ assertThrows(IllegalArgumentException.class, () -> JavaPlatformStringLookup.INSTANCE.apply("BADKEY"));
}
@Test
@@ -41,7 +41,7 @@ public class JavaPlatformStringLookupTest {
@Test
public void testNull() {
- Assertions.assertNull(JavaPlatformStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(JavaPlatformStringLookup.INSTANCE.apply(null));
}
@Test
@@ -53,7 +53,7 @@ public class JavaPlatformStringLookupTest {
@Test
public void testVm() {
final String key = "vm";
- assertTrue(JavaPlatformStringLookup.INSTANCE.lookup(key).contains(System.getProperty("java.vm.name")));
+ assertTrue(JavaPlatformStringLookup.INSTANCE.apply(key).contains(System.getProperty("java.vm.name")));
}
}
diff --git a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
index 917455b6..dc0b09b9 100644
--- a/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/NullStringLookupTest.java
@@ -27,8 +27,8 @@ public class NullStringLookupTest {
@Test
public void test() {
- Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.lookup("EverythingIsNull"));
- Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.lookup(null));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.apply("EverythingIsNull"));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_NULL.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/PropertiesStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/PropertiesStringLookupTest.java
index d7068101..bfffa9ae 100644
--- a/src/test/java/org/apache/commons/text/lookup/PropertiesStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/PropertiesStringLookupTest.java
@@ -51,8 +51,8 @@ public class PropertiesStringLookupTest {
@Test
public void testFenceOne() {
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).lookup(KEY_ROOT));
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(Paths.get("not a dir at all"), CURRENT_PATH).lookup(KEY_ROOT));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).apply(KEY_ROOT));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(Paths.get("not a dir at all"), CURRENT_PATH).apply(KEY_ROOT));
}
@Test
@@ -112,38 +112,38 @@ public class PropertiesStringLookupTest {
@Test
public void testMissingFile() {
- assertThrows(IllegalArgumentException.class, () -> PropertiesStringLookup.INSTANCE.lookup("MissingFile"));
+ assertThrows(IllegalArgumentException.class, () -> PropertiesStringLookup.INSTANCE.apply("MissingFile"));
}
@Test
public void testMissingFileWithKey() {
assertThrows(IllegalArgumentException.class,
- () -> PropertiesStringLookup.INSTANCE.lookup(PropertiesStringLookup.toPropertyKey("MissingFile", "AnyKey")));
+ () -> PropertiesStringLookup.INSTANCE.apply(PropertiesStringLookup.toPropertyKey("MissingFile", "AnyKey")));
}
@Test
public void testMissingKey() {
- assertThrows(IllegalArgumentException.class, () -> PropertiesStringLookup.INSTANCE.lookup(DOC_RELATIVE));
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup().lookup(DOC_RELATIVE));
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(NULL_PATH_ARRAY).lookup(DOC_RELATIVE));
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).lookup(DOC_RELATIVE));
+ assertThrows(IllegalArgumentException.class, () -> PropertiesStringLookup.INSTANCE.apply(DOC_RELATIVE));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup().apply(DOC_RELATIVE));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(NULL_PATH_ARRAY).apply(DOC_RELATIVE));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).apply(DOC_RELATIVE));
}
@Test
public void testNull() {
- Assertions.assertNull(PropertiesStringLookup.INSTANCE.lookup(null));
- Assertions.assertNull(new PropertiesStringLookup().lookup(null));
- Assertions.assertNull(new PropertiesStringLookup(NULL_PATH_ARRAY).lookup(null));
- Assertions.assertNull(new PropertiesStringLookup(CURRENT_PATH).lookup(null));
+ Assertions.assertNull(PropertiesStringLookup.INSTANCE.apply(null));
+ Assertions.assertNull(new PropertiesStringLookup().apply(null));
+ Assertions.assertNull(new PropertiesStringLookup(NULL_PATH_ARRAY).apply(null));
+ Assertions.assertNull(new PropertiesStringLookup(CURRENT_PATH).apply(null));
}
@Test
public void testOne() {
- assertEquals("Hello World!", PropertiesStringLookup.INSTANCE.lookup(KEY_RELATIVE));
- assertEquals("Hello World!", new PropertiesStringLookup().lookup(KEY_RELATIVE));
- assertEquals("Hello World!", new PropertiesStringLookup(NULL_PATH_ARRAY).lookup(KEY_RELATIVE));
- assertEquals("Hello World!", new PropertiesStringLookup(CURRENT_PATH).lookup(KEY_RELATIVE));
- assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).lookup(KEY_ROOT));
+ assertEquals("Hello World!", PropertiesStringLookup.INSTANCE.apply(KEY_RELATIVE));
+ assertEquals("Hello World!", new PropertiesStringLookup().apply(KEY_RELATIVE));
+ assertEquals("Hello World!", new PropertiesStringLookup(NULL_PATH_ARRAY).apply(KEY_RELATIVE));
+ assertEquals("Hello World!", new PropertiesStringLookup(CURRENT_PATH).apply(KEY_RELATIVE));
+ assertThrows(IllegalArgumentException.class, () -> new PropertiesStringLookup(CURRENT_PATH).apply(KEY_ROOT));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
index 7fb0f709..8572ac63 100644
--- a/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ResourceBundleStringLookupTest.java
@@ -40,50 +40,50 @@ public class ResourceBundleStringLookupTest {
final String bundleName = TEST_RESOURCE_BUNDLE;
final String bundleKey = KEY;
Assertions.assertEquals(ResourceBundle.getBundle(bundleName).getString(bundleKey),
- ResourceBundleStringLookup.INSTANCE.lookup(AbstractStringLookup.toLookupKey(bundleName, bundleKey)));
+ ResourceBundleStringLookup.INSTANCE.apply(AbstractStringLookup.toLookupKey(bundleName, bundleKey)));
}
@Test
public void testBadKey() {
final String bundleName = TEST_RESOURCE_BUNDLE;
final String bundleKey = "bad_key";
- assertNull(new ResourceBundleStringLookup(bundleName).lookup(bundleKey));
- assertNull(ResourceBundleStringLookup.INSTANCE.lookup(AbstractStringLookup.toLookupKey(bundleName, bundleKey)));
+ assertNull(new ResourceBundleStringLookup(bundleName).apply(bundleKey));
+ assertNull(ResourceBundleStringLookup.INSTANCE.apply(AbstractStringLookup.toLookupKey(bundleName, bundleKey)));
}
@Test
public void testBadNames() {
assertNull(ResourceBundleStringLookup.INSTANCE
- .lookup(AbstractStringLookup.toLookupKey("BAD_RESOURCE_BUNDLE_NAME", "KEY")));
+ .apply(AbstractStringLookup.toLookupKey("BAD_RESOURCE_BUNDLE_NAME", "KEY")));
}
@Test
public void testDoubleBundle() {
assertThrows(IllegalArgumentException.class, () -> new ResourceBundleStringLookup(TEST_RESOURCE_BUNDLE)
- .lookup(AbstractStringLookup.toLookupKey("OtherBundle", KEY)));
+ .apply(AbstractStringLookup.toLookupKey("OtherBundle", KEY)));
}
@Test
public void testExceptionGettingString() {
final ResourceBundleStringLookup mockLookup = spy(ResourceBundleStringLookup.class);
when(mockLookup.getString(TEST_RESOURCE_BUNDLE, KEY)).thenThrow(ClassCastException.class);
- assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(AbstractStringLookup.toLookupKey(TEST_RESOURCE_BUNDLE, KEY)));
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.apply(AbstractStringLookup.toLookupKey(TEST_RESOURCE_BUNDLE, KEY)));
}
@Test
public void testMissingKeyInSpec() {
- assertThrows(IllegalArgumentException.class, () -> ResourceBundleStringLookup.INSTANCE.lookup(TEST_RESOURCE_BUNDLE + ":"));
+ assertThrows(IllegalArgumentException.class, () -> ResourceBundleStringLookup.INSTANCE.apply(TEST_RESOURCE_BUNDLE + ":"));
}
@Test
public void testNull() {
- Assertions.assertNull(ResourceBundleStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(ResourceBundleStringLookup.INSTANCE.apply(null));
}
@Test
public void testOne() {
Assertions.assertEquals(ResourceBundle.getBundle(TEST_RESOURCE_BUNDLE).getString(KEY),
- new ResourceBundleStringLookup(TEST_RESOURCE_BUNDLE).lookup(KEY));
+ new ResourceBundleStringLookup(TEST_RESOURCE_BUNDLE).apply(KEY));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
index 46853463..da530dc9 100644
--- a/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/ScriptStringLookupTest.java
@@ -33,27 +33,27 @@ public class ScriptStringLookupTest {
@Test
public void testBadEngineName() {
- assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("BAD_ENGINE_NAME:\"Hello World!\""));
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.apply("BAD_ENGINE_NAME:\"Hello World!\""));
}
@Test
public void testBadScript() {
- assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup(JS_NAME + ":X"));
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.apply(JS_NAME + ":X"));
}
@Test
public void testNoScript() {
- assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("ENGINE_NAME:"));
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.apply("ENGINE_NAME:"));
}
@Test
public void testNull() {
- Assertions.assertNull(ScriptStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(ScriptStringLookup.INSTANCE.apply(null));
}
@Test
public void testOne() {
- Assertions.assertEquals("Hello World!", ScriptStringLookup.INSTANCE.lookup(JS_NAME + ":\"Hello World!\""));
+ Assertions.assertEquals("Hello World!", ScriptStringLookup.INSTANCE.apply(JS_NAME + ":\"Hello World!\""));
}
@Test
@@ -63,13 +63,13 @@ public class ScriptStringLookupTest {
@Test
public void testScriptMissingColon() {
- assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.lookup("JavaScript=\"test\""));
+ assertThrows(IllegalArgumentException.class, () -> ScriptStringLookup.INSTANCE.apply("JavaScript=\"test\""));
}
@Test
public void testScriptUsingMultipleColons() {
Assertions.assertEquals("It Works",
- ScriptStringLookup.INSTANCE.lookup(JS_NAME + ":true ? \"It Works\" : \"It Does Not Work\" "));
+ ScriptStringLookup.INSTANCE.apply(JS_NAME + ":true ? \"It Works\" : \"It Does Not Work\" "));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
index 483c695a..0ec15fbb 100644
--- a/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/SystemPropertyStringLookupTest.java
@@ -27,7 +27,7 @@ public class SystemPropertyStringLookupTest {
@Test
public void testNull() {
- Assertions.assertNull(StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.lookup(null));
+ Assertions.assertNull(StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.apply(null));
}
@Test
@@ -39,7 +39,7 @@ public class SystemPropertyStringLookupTest {
@Test
public void testUserName() {
final String key = "user.name";
- Assertions.assertEquals(System.getProperty(key), StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.lookup(key));
+ Assertions.assertEquals(System.getProperty(key), StringLookupFactory.INSTANCE_SYSTEM_PROPERTIES.apply(key));
}
}
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
index 56488ba6..fd70d6d5 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlDecoderStringLookupTest.java
@@ -36,7 +36,7 @@ public class UrlDecoderStringLookupTest {
@Test
public void testAllPercent() {
- Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.lookup("Hello%20World%21"));
+ Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.apply("Hello%20World%21"));
}
@Test
@@ -44,22 +44,22 @@ public class UrlDecoderStringLookupTest {
final UrlDecoderStringLookup mockLookup = spy(UrlDecoderStringLookup.class);
when(mockLookup.decode(DATA, StandardCharsets.UTF_8.displayName()))
.thenThrow(UnsupportedEncodingException.class);
- assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(DATA));
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.apply(DATA));
}
@Test
public void testExclamation() {
- Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.lookup("Hello%20World!"));
+ Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.apply("Hello%20World!"));
}
@Test
public void testNull() {
- Assertions.assertNull(UrlDecoderStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(UrlDecoderStringLookup.INSTANCE.apply(null));
}
@Test
public void testPlus() {
- Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.lookup("Hello+World!"));
+ Assertions.assertEquals(DATA, UrlDecoderStringLookup.INSTANCE.apply("Hello+World!"));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
index 8cfe95f5..663820c0 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlEncoderStringLookupTest.java
@@ -36,7 +36,7 @@ public class UrlEncoderStringLookupTest {
@Test
public void test() {
- Assertions.assertEquals(DATA, UrlEncoderStringLookup.INSTANCE.lookup("Hello World!"));
+ Assertions.assertEquals(DATA, UrlEncoderStringLookup.INSTANCE.apply("Hello World!"));
}
@Test
@@ -44,12 +44,12 @@ public class UrlEncoderStringLookupTest {
final UrlEncoderStringLookup mockLookup = spy(UrlEncoderStringLookup.class);
when(mockLookup.encode(DATA, StandardCharsets.UTF_8.displayName()))
.thenThrow(UnsupportedEncodingException.class);
- assertThrows(IllegalArgumentException.class, () -> mockLookup.lookup(DATA));
+ assertThrows(IllegalArgumentException.class, () -> mockLookup.apply(DATA));
}
@Test
public void testNull() {
- Assertions.assertNull(UrlEncoderStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(UrlEncoderStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
index 93b83fe7..ab7e8e4c 100644
--- a/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/UrlStringLookupTest.java
@@ -35,17 +35,17 @@ public class UrlStringLookupTest {
@Test
public void testBadCharsetName() {
- assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("BAD_CHARSET_NAME:BAD_URL"));
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.apply("BAD_CHARSET_NAME:BAD_URL"));
}
@Test
public void testBadEncoding() {
- assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("FOO:https://www.google.com"));
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.apply("FOO:https://www.google.com"));
}
@Test
public void testBadUrl() {
- assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("UTF-8:BAD_URL"));
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.apply("UTF-8:BAD_URL"));
}
@Test
@@ -55,23 +55,23 @@ public class UrlStringLookupTest {
// System.out.println(uri);
final byte[] expectedBytes = Files.readAllBytes(path);
final String expectedString = new String(expectedBytes, StandardCharsets.UTF_8);
- Assertions.assertEquals(expectedString, UrlStringLookup.INSTANCE.lookup("UTF-8:" + uri.toString()));
+ Assertions.assertEquals(expectedString, UrlStringLookup.INSTANCE.apply("UTF-8:" + uri.toString()));
}
@Test
public void testHttpScheme() {
- Assertions.assertNotNull(UrlStringLookup.INSTANCE.lookup("UTF-8:https://www.apache.org"));
- Assertions.assertNotNull(UrlStringLookup.INSTANCE.lookup("UTF-8:https://www.google.com"));
+ Assertions.assertNotNull(UrlStringLookup.INSTANCE.apply("UTF-8:https://www.apache.org"));
+ Assertions.assertNotNull(UrlStringLookup.INSTANCE.apply("UTF-8:https://www.google.com"));
}
@Test
public void testMissingUrl() {
- assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.lookup("UTF-8"));
+ assertThrows(IllegalArgumentException.class, () -> UrlStringLookup.INSTANCE.apply("UTF-8"));
}
@Test
public void testNull() {
- Assertions.assertNull(UrlStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(UrlStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/XmlDecoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/XmlDecoderStringLookupTest.java
index 6fba2d55..9afff0bf 100644
--- a/src/test/java/org/apache/commons/text/lookup/XmlDecoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/XmlDecoderStringLookupTest.java
@@ -29,12 +29,12 @@ public class XmlDecoderStringLookupTest {
@Test
public void testDecode() {
- Assertions.assertEquals(DATA, XmlDecoderStringLookup.INSTANCE.lookup("<element>"));
+ Assertions.assertEquals(DATA, XmlDecoderStringLookup.INSTANCE.apply("<element>"));
}
@Test
public void testNull() {
- Assertions.assertNull(XmlDecoderStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(XmlDecoderStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/XmlEncoderStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/XmlEncoderStringLookupTest.java
index d5f0615e..a5b4874e 100644
--- a/src/test/java/org/apache/commons/text/lookup/XmlEncoderStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/XmlEncoderStringLookupTest.java
@@ -29,12 +29,12 @@ public class XmlEncoderStringLookupTest {
@Test
public void testDecode() {
- Assertions.assertEquals(DATA, XmlEncoderStringLookup.INSTANCE.lookup("<element>"));
+ Assertions.assertEquals(DATA, XmlEncoderStringLookup.INSTANCE.apply("<element>"));
}
@Test
public void testNull() {
- Assertions.assertNull(XmlEncoderStringLookup.INSTANCE.lookup(null));
+ Assertions.assertNull(XmlEncoderStringLookup.INSTANCE.apply(null));
}
@Test
diff --git a/src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java b/src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java
index 05fc4c2c..cd659caa 100644
--- a/src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java
+++ b/src/test/java/org/apache/commons/text/lookup/XmlStringLookupTest.java
@@ -46,30 +46,30 @@ public class XmlStringLookupTest {
static void assertLookup(final StringLookup xmlStringLookup) {
assertNotNull(xmlStringLookup);
assertInstanceOf(XmlStringLookup.class, xmlStringLookup);
- assertEquals("Hello World!", xmlStringLookup.lookup(DOC_RELATIVE + ":/root/path/to/node"));
- assertNull(xmlStringLookup.lookup(null));
+ assertEquals("Hello World!", xmlStringLookup.apply(DOC_RELATIVE + ":/root/path/to/node"));
+ assertNull(xmlStringLookup.apply(null));
}
@Test
public void testBadXPath() {
- assertThrows(IllegalArgumentException.class, () -> XmlStringLookup.INSTANCE.lookup("docName"));
+ assertThrows(IllegalArgumentException.class, () -> XmlStringLookup.INSTANCE.apply("docName"));
}
@Test
public void testMissingXPath() {
- assertThrows(IllegalArgumentException.class, () -> XmlStringLookup.INSTANCE.lookup(DOC_RELATIVE + ":" + "!JUNK!"));
+ assertThrows(IllegalArgumentException.class, () -> XmlStringLookup.INSTANCE.apply(DOC_RELATIVE + ":" + "!JUNK!"));
}
@Test
public void testNoFeatures() {
final String xpath = "/root/path/to/node";
- assertEquals("Hello World!", new XmlStringLookup(new HashMap<>()).lookup(DOC_RELATIVE + ":" + xpath));
- assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), CURRENT_PATH).lookup(DOC_RELATIVE + ":" + xpath));
- assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), CURRENT_PATH, ABSENT_PATH).lookup(DOC_RELATIVE + ":" + xpath));
- assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), ABSENT_PATH, CURRENT_PATH).lookup(DOC_RELATIVE + ":" + xpath));
- assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), ABSENT_PATH).lookup(DOC_ROOT + ":" + xpath));
- assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), CURRENT_PATH).lookup(DOC_ROOT + ":" + xpath));
- assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), ABSENT_PATH, CURRENT_PATH).lookup(DOC_ROOT + ":" + xpath));
+ assertEquals("Hello World!", new XmlStringLookup(new HashMap<>()).apply(DOC_RELATIVE + ":" + xpath));
+ assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), CURRENT_PATH).apply(DOC_RELATIVE + ":" + xpath));
+ assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), CURRENT_PATH, ABSENT_PATH).apply(DOC_RELATIVE + ":" + xpath));
+ assertEquals("Hello World!", new XmlStringLookup(new HashMap<>(), ABSENT_PATH, CURRENT_PATH).apply(DOC_RELATIVE + ":" + xpath));
+ assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), ABSENT_PATH).apply(DOC_ROOT + ":" + xpath));
+ assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), CURRENT_PATH).apply(DOC_ROOT + ":" + xpath));
+ assertThrows(IllegalArgumentException.class, () -> new XmlStringLookup(new HashMap<>(), ABSENT_PATH, CURRENT_PATH).apply(DOC_ROOT + ":" + xpath));
}
@Test
@@ -81,7 +81,7 @@ public class XmlStringLookupTest {
@Test
public void testNull() {
- assertNull(XmlStringLookup.INSTANCE.lookup(null));
+ assertNull(XmlStringLookup.INSTANCE.apply(null));
}
@Test
(commons-text) 02/04: Interface StringLookup now extends UnaryOperator
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-text.git
commit 7a799b2d26d7fc57826e619587384e20aaba4366
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue May 20 10:44:48 2025 -0400
Interface StringLookup now extends UnaryOperator<String>
---
src/main/java/org/apache/commons/text/lookup/StringLookup.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/text/lookup/StringLookup.java b/src/main/java/org/apache/commons/text/lookup/StringLookup.java
index b59bbc0a..bc209284 100644
--- a/src/main/java/org/apache/commons/text/lookup/StringLookup.java
+++ b/src/main/java/org/apache/commons/text/lookup/StringLookup.java
@@ -62,7 +62,7 @@ public interface StringLookup extends UnaryOperator<String> {
* @since 1.14.0
*/
@Override
- default String apply(String key) {
+ default String apply(final String key) {
return lookup(key);
}