From d00901b1fd902d35f211f7d1770b259d8ce474b4 Mon Sep 17 00:00:00 2001 From: Markus KARG Date: Thu, 29 Jun 2017 23:33:04 +0200 Subject: [PATCH] Replaced custom code by Java 7 methods (#30) This closes #30 --- .../java/org/codehaus/plexus/util/StringUtils.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codehaus/plexus/util/StringUtils.java b/src/main/java/org/codehaus/plexus/util/StringUtils.java index 4092c401..b52a5a3b 100644 --- a/src/main/java/org/codehaus/plexus/util/StringUtils.java +++ b/src/main/java/org/codehaus/plexus/util/StringUtils.java @@ -57,6 +57,7 @@ import java.util.Iterator; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.StringTokenizer; /** @@ -258,10 +259,12 @@ public static boolean isNotBlank( String str ) * @param str1 the first string * @param str2 the second string * @return true if the Strings are equal, case sensitive, or both null + * @see Objects#equals(Object, Object) */ + @Deprecated public static boolean equals( String str1, String str2 ) { - return ( str1 == null ? str2 == null : str1.equals( str2 ) ); + return Objects.equals( str1, str2 ); } /** @@ -2038,7 +2041,9 @@ public static boolean isNumericSpace( String str ) * * @param obj the Object to check * @return the passed in Object's toString, or blank if it was null + * @see Objects#toString(Object, String) */ + @Deprecated public static String defaultString( Object obj ) { return defaultString( obj, "" ); @@ -2053,10 +2058,12 @@ public static String defaultString( Object obj ) * @param obj the Object to check * @param defaultString the default String to return if str is null * @return the passed in string, or the default if it was null + * @see Objects#toString(Object, String) */ + @Deprecated public static String defaultString( Object obj, String defaultString ) { - return ( obj == null ) ? defaultString : obj.toString(); + return Objects.toString( obj, defaultString ); } // Reversing