HHH-14190 Rename isEmptyOrWhitespace() to isBlank()
and use it in more places
This commit is contained in:
parent
3b32bb9ecd
commit
c6728684bb
|
@ -43,7 +43,7 @@ public class FilterSourceImpl
|
|||
for ( Serializable content : filterElement.getContent() ) {
|
||||
if ( String.class.isInstance( content ) ) {
|
||||
final String str = content.toString();
|
||||
if ( !StringHelper.isEmptyOrWhiteSpace( str ) ) {
|
||||
if ( !StringHelper.isBlank( str ) ) {
|
||||
conditionContent = str.trim();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ public class Example implements Criterion {
|
|||
}
|
||||
|
||||
final String conditionFragment = condition.toSqlString( criteria, cq );
|
||||
if ( conditionFragment.trim().length() > 0 ) {
|
||||
if ( !StringHelper.isBlank( conditionFragment ) ) {
|
||||
if ( buf.length() > 1 ) {
|
||||
buf.append( " and " );
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ public class JoinSequence {
|
|||
* @return {@link this}, for method chaining
|
||||
*/
|
||||
public JoinSequence addCondition(String condition) {
|
||||
if ( condition.trim().length() != 0 ) {
|
||||
if ( !StringHelper.isBlank( condition ) ) {
|
||||
if ( !condition.startsWith( " and " ) ) {
|
||||
conditions.append( " and " );
|
||||
}
|
||||
|
|
|
@ -472,10 +472,19 @@ public final class StringHelper {
|
|||
return string == null || string.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isEmptyOrWhiteSpace(String string) {
|
||||
public static boolean isBlank(String string) {
|
||||
return isEmpty( string ) || isEmpty( string.trim() );
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #isBlank(String)}
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isEmptyOrWhitespace(String string) {
|
||||
return isBlank(string);
|
||||
}
|
||||
|
||||
public static String qualify(String prefix, String name) {
|
||||
if ( name == null || prefix == null ) {
|
||||
throw new NullPointerException( "prefix or name were null attempting to build qualified name" );
|
||||
|
|
|
@ -1112,7 +1112,7 @@ public class JoinWalker {
|
|||
collectionSuffix,
|
||||
join.getJoinType() == JoinType.LEFT_OUTER_JOIN
|
||||
);
|
||||
if ( selectFragment.trim().length() > 0 ) {
|
||||
if ( !StringHelper.isBlank( selectFragment ) ) {
|
||||
buf.append( ", " ).append( selectFragment );
|
||||
}
|
||||
if ( joinable.consumesEntityAlias() ) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Map;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.internal.JoinHelper;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.persister.collection.QueryableCollection;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.sql.JoinFragment;
|
||||
|
@ -77,7 +78,7 @@ public final class OuterJoinableAssociation {
|
|||
this.joinable = joinableType.getAssociatedJoinable( factory );
|
||||
this.rhsColumns = JoinHelper.getRHSColumnNames( joinableType, factory );
|
||||
this.on = joinableType.getOnCondition( rhsAlias, factory, enabledFilters )
|
||||
+ ( withClause == null || withClause.trim().length() == 0 ? "" : " and ( " + withClause + " )" );
|
||||
+ ( StringHelper.isBlank( withClause ) ? "" : " and ( " + withClause + " )" );
|
||||
this.hasRestriction = hasRestriction;
|
||||
this.enabledFilters = enabledFilters; // needed later for many-to-many/filter application
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
|
|||
""
|
||||
)
|
||||
);
|
||||
if ( ! StringHelper.isEmptyOrWhiteSpace( extraPhysycalTableTypesConfig ) ) {
|
||||
if ( ! StringHelper.isBlank( extraPhysycalTableTypesConfig ) ) {
|
||||
this.extraPhysicalTableTypes = StringHelper.splitTrimmingTokens(
|
||||
",;",
|
||||
extraPhysycalTableTypesConfig,
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.persistence.Version;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -142,7 +143,7 @@ public class EmbeddableWithManyToMany_HHH_11302_Test
|
|||
result += "id: " + id;
|
||||
}
|
||||
result += ", version: " + version;
|
||||
if ( type != null && !type.trim().isEmpty() ) {
|
||||
if ( !StringHelper.isBlank( type ) ) {
|
||||
result += ", type: " + type;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -27,6 +27,7 @@ import javax.persistence.Version;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
@ -142,7 +143,7 @@ public class EmbeddableWithOneToMany_HHH_11302_Test
|
|||
result += "id: " + id;
|
||||
}
|
||||
result += ", version: " + version;
|
||||
if ( type != null && !type.trim().isEmpty() ) {
|
||||
if ( !StringHelper.isBlank( type ) ) {
|
||||
result += ", type: " + type;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.hibernate.test.annotations.embeddables.collection.xml;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
@ -71,7 +73,7 @@ public class ContactType implements Serializable {
|
|||
result += "id: " + id;
|
||||
}
|
||||
result += ", version: " + version;
|
||||
if ( type != null && !type.trim().isEmpty() ) {
|
||||
if ( !StringHelper.isBlank( type ) ) {
|
||||
result += ", type: " + type;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.sql.PreparedStatement;
|
|||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
@ -55,7 +56,7 @@ public class MyCustomSqlTypeDescriptor implements SqlTypeDescriptor {
|
|||
@Override
|
||||
protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException {
|
||||
final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options );
|
||||
if ( valueStr == null || valueStr.trim().isEmpty() ) {
|
||||
if ( StringHelper.isBlank( valueStr ) ) {
|
||||
st.setNull( index, getSqlType() );
|
||||
}
|
||||
else {
|
||||
|
@ -66,7 +67,7 @@ public class MyCustomSqlTypeDescriptor implements SqlTypeDescriptor {
|
|||
@Override
|
||||
protected void doBind(CallableStatement st, X value, String name, WrapperOptions options) throws SQLException {
|
||||
final String valueStr = javaTypeDescriptor.unwrap( value, String.class, options );
|
||||
if ( valueStr == null || valueStr.trim().isEmpty() ) {
|
||||
if ( StringHelper.isBlank( valueStr ) ) {
|
||||
st.setNull( name, getSqlType() );
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -13,9 +13,7 @@ import java.util.Map;
|
|||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.Criteria;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.criterion.CriteriaSpecification;
|
||||
import org.hibernate.criterion.Restrictions;
|
||||
import org.hibernate.sql.JoinFragment;
|
||||
import org.hibernate.sql.JoinType;
|
||||
|
@ -622,7 +620,4 @@ public class OuterJoinCriteriaTest extends BaseCoreFunctionalTestCase {
|
|||
s.close();
|
||||
}
|
||||
|
||||
private static boolean isBlank(String s) {
|
||||
return s == null || s.trim().length() == 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue