diff --git a/hibernate-core/src/main/java/org/hibernate/boot/SchemaAutoTooling.java b/hibernate-core/src/main/java/org/hibernate/boot/SchemaAutoTooling.java index 78893e403e..953b10a5a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/SchemaAutoTooling.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/SchemaAutoTooling.java @@ -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'." ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 4f858eab41..3e02689267 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -2817,7 +2817,7 @@ public abstract class Dialect implements ConversionContext { public String getQueryHintString(String query, List hintList) { final String hints = String.join( ", ", hintList ); - if ( StringHelper.isEmpty( hints ) ) { + if ( hints.isEmpty() ) { return query; } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java index a8d41766eb..ef46cdfbf2 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/query/spi/ParameterParser.java @@ -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 + "]" ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/Node.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/Node.java index 9e5071362d..4aff24cbda 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/Node.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/Node.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SyntheticAndFactory.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SyntheticAndFactory.java index 4393889150..6be760ced1 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SyntheticAndFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/util/SyntheticAndFactory.java @@ -60,7 +60,7 @@ public class SyntheticAndFactory implements HqlSqlTokenTypes { } whereFragment = whereFragment.trim(); - if ( StringHelper.isEmpty( whereFragment ) ) { + if ( whereFragment.isEmpty() ) { return; } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java b/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java index 2e5214a6ae..fe97b287cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/config/ConfigurationHelper.java @@ -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) { diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java index c29459e04a..7a6c2d1aa8 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/boot/internal/PersistenceXmlParser.java @@ -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, "" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/PersistenceUnitTransactionTypeHelper.java b/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/PersistenceUnitTransactionTypeHelper.java index a984ff45fa..8577a8430f 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/PersistenceUnitTransactionTypeHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/internal/util/PersistenceUnitTransactionTypeHelper.java @@ -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 + '\'' ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/PhysicalConnectionHandlingMode.java b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/PhysicalConnectionHandlingMode.java index ca9cd77f19..48f08e9da2 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/PhysicalConnectionHandlingMode.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/PhysicalConnectionHandlingMode.java @@ -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; } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SingleLineSqlCommandExtractor.java b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SingleLineSqlCommandExtractor.java index 0df55056a6..e794b39444 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SingleLineSqlCommandExtractor.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/hbm2ddl/SingleLineSqlCommandExtractor.java @@ -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( ";" ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/Action.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/Action.java index d0acffaeae..c7c5b375f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/Action.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/Action.java @@ -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; } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java index a25c53ed54..2737b85e7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/JdbcMetadaAccessStrategy.java @@ -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 + '`'); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/tool/schema/SourceType.java b/hibernate-core/src/main/java/org/hibernate/tool/schema/SourceType.java index b3059e1810..7755edd9a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/tool/schema/SourceType.java +++ b/hibernate-core/src/main/java/org/hibernate/tool/schema/SourceType.java @@ -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 + '\''); } } diff --git a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/MissingCacheStrategy.java b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/MissingCacheStrategy.java index 1fc9067940..03683b46e3 100644 --- a/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/MissingCacheStrategy.java +++ b/hibernate-ehcache/src/main/java/org/hibernate/cache/ehcache/MissingCacheStrategy.java @@ -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 + '`'); } } diff --git a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/MissingCacheStrategy.java b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/MissingCacheStrategy.java index b9ef31c95c..edba1b44e6 100644 --- a/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/MissingCacheStrategy.java +++ b/hibernate-jcache/src/main/java/org/hibernate/cache/jcache/MissingCacheStrategy.java @@ -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 + '`'); } }