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) { 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; return null;
} }
else if ( VALIDATE.externalForm.equals( configurationValue ) ) { else if ( VALIDATE.externalForm.equals( configurationValue ) ) {
@ -76,8 +80,8 @@ public enum SchemaAutoTooling {
} }
else { else {
throw new HibernateException( throw new HibernateException(
"Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value: " + configurationValue "Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value: '" + configurationValue
+ ". Supported values include 'create', 'create-drop', 'create-only', 'drop', 'update', 'none' and 'validate'." + "'. 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) { public String getQueryHintString(String query, List<String> hintList) {
final String hints = String.join( ", ", hintList ); final String hints = String.join( ", ", hintList );
if ( StringHelper.isEmpty( hints ) ) { if ( hints.isEmpty() ) {
return query; 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 right = StringHelper.firstIndexOfChar( sqlString, ParserHelper.HQL_SEPARATORS_BITSET, indx + 1 );
final int chopLocation = right < 0 ? sqlString.length() : right; final int chopLocation = right < 0 ? sqlString.length() : right;
final String param = sqlString.substring( indx + 1, chopLocation ); final String param = sqlString.substring( indx + 1, chopLocation );
if ( StringHelper.isEmpty( param ) ) { if ( param.isEmpty() ) {
throw new QueryException( throw new QueryException(
"Space is not allowed after parameter prefix ':' [" + sqlString + "]" "Space is not allowed after parameter prefix ':' [" + sqlString + "]"
); );

View File

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

View File

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

View File

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

View File

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

View File

@ -27,8 +27,8 @@ public class PersistenceUnitTransactionTypeHelper {
return (PersistenceUnitTransactionType) value; return (PersistenceUnitTransactionType) value;
} }
final String stringValue = value.toString(); final String stringValue = value.toString().trim();
if ( StringHelper.isEmpty( stringValue ) ) { if ( stringValue.isEmpty() ) {
return null; return null;
} }
else if ( stringValue.equalsIgnoreCase( "JTA" ) ) { else if ( stringValue.equalsIgnoreCase( "JTA" ) ) {
@ -38,7 +38,7 @@ public class PersistenceUnitTransactionTypeHelper {
return PersistenceUnitTransactionType.RESOURCE_LOCAL; return PersistenceUnitTransactionType.RESOURCE_LOCAL;
} }
else { 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; return (PhysicalConnectionHandlingMode) setting;
} }
final String value = setting.toString(); final String value = setting.toString().trim();
if ( StringHelper.isEmpty( value ) ) { if ( value.isEmpty() ) {
return null; return null;
} }

View File

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

View File

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

View File

@ -62,15 +62,15 @@ public enum JdbcMetadaAccessStrategy {
return GROUPED; return GROUPED;
} }
else { else {
final String name = value.toString(); final String name = value.toString().trim();
if ( StringHelper.isEmpty( name ) || GROUPED.strategy.equals( name ) ) { if ( name.isEmpty() || GROUPED.strategy.equals( name ) ) {
return GROUPED; return GROUPED;
} }
else if ( INDIVIDUALLY.strategy.equals( name ) ) { else if ( INDIVIDUALLY.strategy.equals( name ) ) {
return INDIVIDUALLY; return INDIVIDUALLY;
} }
else { 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; return (SourceType) value;
} }
final String name = value.toString(); final String name = value.toString().trim();
if ( StringHelper.isEmpty( name ) ) { if ( name.isEmpty() ) {
// empty is in fact valid as means to interpret default value based on other settings // empty is in fact valid as means to interpret default value based on other settings
return defaultValue; return defaultValue;
} }
@ -93,6 +93,6 @@ public enum SourceType {
return SCRIPT_THEN_METADATA; 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; return (MissingCacheStrategy) value;
} }
final String externalRepresentation = value == null ? null : value.toString(); final String externalRepresentation = value == null ? null : value.toString().trim();
if ( StringHelper.isEmpty( externalRepresentation ) ) { if ( StringHelper.isEmpty( externalRepresentation ) ) {
// Use the default // 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; return (MissingCacheStrategy) value;
} }
final String externalRepresentation = value == null ? null : value.toString(); final String externalRepresentation = value == null ? null : value.toString().trim();
if ( StringHelper.isEmpty( externalRepresentation ) ) { if ( StringHelper.isEmpty( externalRepresentation ) ) {
// Use the default // 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 + '`');
} }
} }