HHH-13549 Simplify StringHelper#isQuoted

This commit is contained in:
Sanne Grinovero 2019-08-07 22:10:51 +01:00
parent de8d6d095f
commit 85d4ffda14
1 changed files with 9 additions and 4 deletions

View File

@ -604,10 +604,15 @@ public final class StringHelper {
*
* @return True if the given string starts and ends with '`'; false otherwise.
*/
public static boolean isQuoted(String name) {
return name != null && name.length() != 0
&& ( ( name.charAt( 0 ) == '`' && name.charAt( name.length() - 1 ) == '`' )
|| ( name.charAt( 0 ) == '"' && name.charAt( name.length() - 1 ) == '"' ) );
public static boolean isQuoted(final String name) {
if ( name == null || name.isEmpty() ) {
return false;
}
final char first = name.charAt( 0 );
final char last = name.charAt( name.length() - 1 );
return ( ( first == last ) && ( first == '`' || first == '"' ) );
}
/**