HHH-13443 Remove unnecessary calls to StringHelper

This commit is contained in:
Sanne Grinovero 2019-06-20 22:00:55 +01:00
parent 084c91c3d0
commit e476a99250
15 changed files with 33 additions and 29 deletions

View File

@ -53,7 +53,11 @@ public enum SchemaAutoTooling {
}
public static SchemaAutoTooling interpret(String configurationValue) {
if ( StringHelper.isEmpty( configurationValue ) || NONE.externalForm.equals( configurationValue ) ) {
if ( configurationValue == null ) {
return null;
}
configurationValue = configurationValue.trim();
if ( configurationValue.isEmpty() || NONE.externalForm.equals( configurationValue ) ) {
return null;
}
else if ( VALIDATE.externalForm.equals( configurationValue ) ) {
@ -76,8 +80,8 @@ public enum SchemaAutoTooling {
}
else {
throw new HibernateException(
"Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value: " + configurationValue
+ ". Supported values include 'create', 'create-drop', 'create-only', 'drop', 'update', 'none' and 'validate'."
"Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value: '" + configurationValue
+ "'. Supported values include 'create', 'create-drop', 'create-only', 'drop', 'update', 'none' and 'validate'."
);
}
}

View File

@ -2817,7 +2817,7 @@ public abstract class Dialect implements ConversionContext {
public String getQueryHintString(String query, List<String> hintList) {
final String hints = String.join( ", ", hintList );
if ( StringHelper.isEmpty( hints ) ) {
if ( hints.isEmpty() ) {
return query;
}

View File

@ -171,7 +171,7 @@ public class ParameterParser {
final int right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS_BITSET, indx + 1 );
final int chopLocation = right < 0 ? sqlString.length() : right;
final String param = sqlString.substring( indx + 1, chopLocation );
if ( StringHelper.isEmpty( param ) ) {
if ( param.isEmpty() ) {
throw new QueryException(
"Space is not allowed after parameter prefix ':' [" + sqlString + "]"
);

View File

@ -50,7 +50,7 @@ public class Node extends antlr.CommonAST {
line = tok.getLine();
column = tok.getColumn();
String text = tok.getText();
textLength = StringHelper.isEmpty(text) ? 0 : text.length();
textLength = StringHelper.isEmpty( text ) ? 0 : text.length();
}
@Override

View File

@ -60,7 +60,7 @@ public class SyntheticAndFactory implements HqlSqlTokenTypes {
}
whereFragment = whereFragment.trim();
if ( StringHelper.isEmpty( whereFragment ) ) {
if ( whereFragment.isEmpty() ) {
return;
}

View File

@ -293,7 +293,7 @@ public final class ConfigurationHelper {
return null;
}
value = value.trim();
if ( StringHelper.isEmpty( value ) ) {
if ( value.isEmpty() ) {
return null;
}
return value;
@ -313,7 +313,7 @@ public final class ConfigurationHelper {
return null;
}
value = value.trim();
if ( StringHelper.isEmpty( value ) ) {
if ( value.isEmpty() ) {
return null;
}
return value;
@ -466,7 +466,7 @@ public final class ConfigurationHelper {
buff.append( chars[pos] );
}
String rtn = buff.toString();
return StringHelper.isEmpty( rtn ) ? null : rtn;
return rtn.isEmpty() ? null : rtn;
}
private static String extractFromSystem(String systemPropertyName) {

View File

@ -369,7 +369,7 @@ public class PersistenceXmlParser {
}
String propName = propElement.getAttribute( "name" ).trim();
String propValue = propElement.getAttribute( "value" ).trim();
if ( StringHelper.isEmpty( propValue ) ) {
if ( propValue.isEmpty() ) {
//fall back to the natural (Hibernate) way of description
propValue = extractContent( propElement, "" );
}

View File

@ -27,8 +27,8 @@ public class PersistenceUnitTransactionTypeHelper {
return (PersistenceUnitTransactionType) value;
}
final String stringValue = value.toString();
if ( StringHelper.isEmpty( stringValue ) ) {
final String stringValue = value.toString().trim();
if ( stringValue.isEmpty() ) {
return null;
}
else if ( stringValue.equalsIgnoreCase( "JTA" ) ) {
@ -38,7 +38,7 @@ public class PersistenceUnitTransactionTypeHelper {
return PersistenceUnitTransactionType.RESOURCE_LOCAL;
}
else {
throw new PersistenceException( "Unknown TransactionType: " + stringValue );
throw new PersistenceException( "Unknown TransactionType: '" + stringValue + '\'' );
}
}
}

View File

@ -74,8 +74,8 @@ public enum PhysicalConnectionHandlingMode {
return (PhysicalConnectionHandlingMode) setting;
}
final String value = setting.toString();
if ( StringHelper.isEmpty( value ) ) {
final String value = setting.toString().trim();
if ( value.isEmpty() ) {
return null;
}

View File

@ -28,7 +28,7 @@ public class SingleLineSqlCommandExtractor implements ImportSqlCommandExtractor
try {
for ( String sql = bufferedReader.readLine(); sql != null; sql = bufferedReader.readLine() ) {
String trimmedSql = sql.trim();
if ( StringHelper.isEmpty( trimmedSql ) || isComment( trimmedSql ) ) {
if ( trimmedSql.isEmpty() || isComment( trimmedSql ) ) {
continue;
}
if ( trimmedSql.endsWith( ";" ) ) {

View File

@ -102,7 +102,7 @@ public enum Action {
}
final String name = value.toString();
if ( StringHelper.isEmpty( name ) || NONE.externalJpaName.equals( name ) ) {
if ( name.isEmpty() || NONE.externalJpaName.equals( name ) ) {
// default is NONE
return NONE;
}
@ -151,7 +151,7 @@ public enum Action {
}
final String name = value.toString().trim();
if ( StringHelper.isEmpty( name ) || NONE.externalJpaName.equals( name ) ) {
if ( name.isEmpty() || NONE.externalJpaName.equals( name ) ) {
// default is NONE
return NONE;
}

View File

@ -62,15 +62,15 @@ public enum JdbcMetadaAccessStrategy {
return GROUPED;
}
else {
final String name = value.toString();
if ( StringHelper.isEmpty( name ) || GROUPED.strategy.equals( name ) ) {
final String name = value.toString().trim();
if ( name.isEmpty() || GROUPED.strategy.equals( name ) ) {
return GROUPED;
}
else if ( INDIVIDUALLY.strategy.equals( name ) ) {
return INDIVIDUALLY;
}
else {
throw new IllegalArgumentException( "Unrecognized `" + AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY + "` value : " + name );
throw new IllegalArgumentException( "Unrecognized `" + AvailableSettings.HBM2DDL_JDBC_METADATA_EXTRACTOR_STRATEGY + "` value : `" + name + '`');
}
}
}

View File

@ -74,8 +74,8 @@ public enum SourceType {
return (SourceType) value;
}
final String name = value.toString();
if ( StringHelper.isEmpty( name ) ) {
final String name = value.toString().trim();
if ( name.isEmpty() ) {
// empty is in fact valid as means to interpret default value based on other settings
return defaultValue;
}
@ -93,6 +93,6 @@ public enum SourceType {
return SCRIPT_THEN_METADATA;
}
throw new IllegalArgumentException( "Unrecognized schema generation source-type value : " + value );
throw new IllegalArgumentException( "Unrecognized schema generation source-type value : '" + value + '\'');
}
}

View File

@ -45,7 +45,7 @@ public enum MissingCacheStrategy {
return (MissingCacheStrategy) value;
}
final String externalRepresentation = value == null ? null : value.toString();
final String externalRepresentation = value == null ? null : value.toString().trim();
if ( StringHelper.isEmpty( externalRepresentation ) ) {
// Use the default
@ -59,6 +59,6 @@ public enum MissingCacheStrategy {
}
}
throw new IllegalArgumentException( "Unrecognized missing cache strategy value : " + value );
throw new IllegalArgumentException( "Unrecognized missing cache strategy value : `" + value + '`');
}
}

View File

@ -48,7 +48,7 @@ public enum MissingCacheStrategy {
return (MissingCacheStrategy) value;
}
final String externalRepresentation = value == null ? null : value.toString();
final String externalRepresentation = value == null ? null : value.toString().trim();
if ( StringHelper.isEmpty( externalRepresentation ) ) {
// Use the default
@ -61,6 +61,6 @@ public enum MissingCacheStrategy {
}
}
throw new IllegalArgumentException( "Unrecognized missing cache strategy value : " + value );
throw new IllegalArgumentException( "Unrecognized missing cache strategy value : `" + value + '`');
}
}