diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java index 6578bd276d..0a9fa4144e 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/DatabaseIdentifier.java @@ -4,7 +4,7 @@ */ package org.hibernate.boot.model.naming; -import org.hibernate.internal.util.StringHelper; +import static org.hibernate.internal.util.StringHelper.isEmpty; /** * Models an identifier (name), retrieved from the database. @@ -24,13 +24,13 @@ public class DatabaseIdentifier extends Identifier { } public static DatabaseIdentifier toIdentifier(String text) { - if ( StringHelper.isEmpty( text ) ) { + if ( isEmpty( text ) ) { return null; } else if ( isQuoted( text ) ) { // exclude the quotes from text - final String unquotedtext = text.substring( 1, text.length() - 1 ); - return new DatabaseIdentifier( unquotedtext ); + final String unquoted = text.substring( 1, text.length() - 1 ); + return new DatabaseIdentifier( unquoted ); } else { return new DatabaseIdentifier( text ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java index 764034ea56..61398e34f6 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/naming/Identifier.java @@ -7,9 +7,12 @@ package org.hibernate.boot.model.naming; import java.util.Locale; import org.hibernate.dialect.Dialect; -import org.hibernate.internal.util.StringHelper; +import static java.lang.Character.isLetter; +import static java.lang.Character.isLetterOrDigit; +import static java.lang.Character.isWhitespace; import static org.hibernate.internal.util.StringHelper.isBlank; +import static org.hibernate.internal.util.StringHelper.isEmpty; /** * Models an identifier (name), which may or may not be quoted. @@ -83,13 +86,13 @@ public class Identifier implements Comparable { int start = 0; int end = text.length(); while ( start < end ) { - if ( !Character.isWhitespace( text.charAt( start ) ) ) { + if ( !isWhitespace( text.charAt( start ) ) ) { break; } start++; } while ( start < end ) { - if ( !Character.isWhitespace( text.charAt( end - 1 ) ) ) { + if ( !isWhitespace( text.charAt( end - 1 ) ) ) { break; } end--; @@ -102,14 +105,14 @@ public class Identifier implements Comparable { else if ( quoteOnNonIdentifierChar && !quote ) { // Check the letters to determine if we must quote the text char c = text.charAt( start ); - if ( !Character.isLetter( c ) && c != '_' ) { + if ( !isLetter( c ) && c != '_' ) { // SQL identifiers must begin with a letter or underscore quote = true; } else { for ( int i = start + 1; i < end; i++ ) { c = text.charAt( i ); - if ( !Character.isLetterOrDigit( c ) && c != '_' ) { + if ( !isLetterOrDigit( c ) && c != '_' ) { quote = true; break; } @@ -163,7 +166,7 @@ public class Identifier implements Comparable { * @param quoted Is this a quoted identifier? */ public Identifier(String text, boolean quoted) { - if ( StringHelper.isEmpty( text ) ) { + if ( isEmpty( text ) ) { throw new IllegalIdentifierException( "Identifier text cannot be null" ); } if ( isQuoted( text ) ) { @@ -234,11 +237,9 @@ public class Identifier implements Comparable { @Override public boolean equals(Object o) { - if ( !(o instanceof Identifier) ) { + if ( !(o instanceof Identifier that) ) { return false; } - - final Identifier that = (Identifier) o; return getCanonicalName().equals( that.getCanonicalName() ); }