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 2022/06/02 10:13:54 UTC
[commons-text] branch master updated: Use Objects.toString()
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
The following commit(s) were added to refs/heads/master by this push:
new e22c3f15 Use Objects.toString()
e22c3f15 is described below
commit e22c3f15c2df8dbbcb052bf7d58b63ae99ea2f12
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Jun 2 06:13:50 2022 -0400
Use Objects.toString()
---
src/main/java/org/apache/commons/text/StrLookup.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/commons/text/StrLookup.java b/src/main/java/org/apache/commons/text/StrLookup.java
index 2220be26..d16a7ed3 100644
--- a/src/main/java/org/apache/commons/text/StrLookup.java
+++ b/src/main/java/org/apache/commons/text/StrLookup.java
@@ -16,7 +16,9 @@
*/
package org.apache.commons.text;
+import java.util.Collections;
import java.util.Map;
+import java.util.Objects;
import java.util.ResourceBundle;
import org.apache.commons.text.lookup.StringLookup;
@@ -60,7 +62,7 @@ public abstract class StrLookup<V> implements StringLookup {
* @param map the map of keys to values, may be null
*/
MapStrLookup(final Map<String, V> map) {
- this.map = map;
+ this.map = map != null ? map : Collections.emptyMap();
}
/**
@@ -74,14 +76,7 @@ public abstract class StrLookup<V> implements StringLookup {
*/
@Override
public String lookup(final String key) {
- if (map == null) {
- return null;
- }
- final Object obj = map.get(key);
- if (obj == null) {
- return null;
- }
- return obj.toString();
+ return Objects.toString(map.get(key), null);
}
@Override