fix some warnings in IntelliJ (unnecessary StringBuilder)

This commit is contained in:
Gavin King 2022-01-09 12:35:20 +01:00
parent 4324509a59
commit bd8bf15e00
10 changed files with 37 additions and 70 deletions

View File

@ -830,10 +830,9 @@ public class AnnotatedColumn {
@Override
public String toString() {
return "Ejb3Column" + "{table=" + getTable()
+ ", mappingColumn=" + mappingColumn.getName()
+ ", insertable=" + insertable
+ ", updatable=" + updatable
+ ", unique=" + unique + '}';
return String.format(
"Ejb3Column{table=%s, mappingColumn=%s, insertable=%s, updatable=%s, unique=%s}",
getTable(), mappingColumn.getName(), insertable, updatable, unique
);
}
}

View File

@ -85,11 +85,8 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "Ejb3DiscriminatorColumn" );
sb.append( "{logicalColumnName'" ).append( getLogicalColumnName() ).append( '\'' );
sb.append( ", discriminatorTypeName='" ).append( discriminatorTypeName ).append( '\'' );
sb.append( '}' );
return sb.toString();
return String.format("Ejb3DiscriminatorColumn{logicalColumnName'%s', discriminatorTypeName='%s'}",
getLogicalColumnName(), discriminatorTypeName
);
}
}

View File

@ -972,12 +972,9 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "Ejb3JoinColumn" );
sb.append( "{logicalColumnName='" ).append( getLogicalColumnName() ).append( '\'' );
sb.append( ", referencedColumn='" ).append( referencedColumn ).append( '\'' );
sb.append( ", mappedBy='" ).append( mappedBy ).append( '\'' );
sb.append( '}' );
return sb.toString();
return String.format(
"Ejb3JoinColumn{logicalColumnName='%s', referencedColumn='%s', mappedBy='%s'}",
getLogicalColumnName(), referencedColumn, mappedBy
);
}
}

View File

@ -133,10 +133,9 @@ public class BinderHelper {
* We need to shallow copy those properties to mark them
* as non insertable / non updatable
*/
StringBuilder propertyNameBuffer = new StringBuilder( "_" );
propertyNameBuffer.append( associatedClass.getEntityName().replace( '.', '_' ) );
propertyNameBuffer.append( "_" ).append( columns[0].getPropertyName().replace( '.', '_' ) );
String syntheticPropertyName = propertyNameBuffer.toString();
String syntheticPropertyName =
"_" + associatedClass.getEntityName().replace('.', '_') +
"_" + columns[0].getPropertyName().replace('.', '_');
//find properties associated to a certain column
Object columnOwner = findColumnOwner( ownerEntity, columns[0].getReferencedColumn(), context );
List<Property> properties = findPropertiesByColumns( columnOwner, columns, context );

View File

@ -73,9 +73,9 @@ public abstract class CollectionSecondPass implements SecondPass {
private static String columns(Value val) {
StringBuilder columns = new StringBuilder();
Iterator iter = val.getColumnIterator();
Iterator<Selectable> iter = val.getColumnIterator();
while ( iter.hasNext() ) {
columns.append( ( (Selectable) iter.next() ).getText() );
columns.append( iter.next().getText() );
if ( iter.hasNext() ) columns.append( ", " );
}
return columns.toString();

View File

@ -29,14 +29,8 @@ public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamin
String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
String propertyName
) {
return tableName(
new StringBuilder( ownerEntityTable ).append( "_" )
.append(
associatedEntityTable != null ?
associatedEntityTable :
addUnderscores( propertyName )
).toString()
);
String entityTableName = associatedEntityTable != null ? associatedEntityTable : addUnderscores(propertyName);
return tableName( ownerEntityTable + "_" + entityTableName );
}
@ -61,12 +55,8 @@ public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamin
return tableName;
}
else {
return new StringBuilder( ownerEntityTable ).append( "_" )
.append(
associatedEntityTable != null ?
associatedEntityTable :
propertyName
).toString();
String entityTableName = associatedEntityTable != null ? associatedEntityTable : propertyName;
return ownerEntityTable + "_" + entityTableName;
}
}

View File

@ -97,12 +97,10 @@ public class DefaultNamingStrategy implements NamingStrategy, Serializable {
return tableName;
}
else {
return new StringBuilder(ownerEntityTable).append("_")
.append(
associatedEntityTable != null ?
associatedEntityTable :
StringHelper.unqualify( propertyName )
).toString();
String entityTableName = associatedEntityTable != null
? associatedEntityTable
: StringHelper.unqualify(propertyName);
return ownerEntityTable + "_" + entityTableName;
}
}
/**

View File

@ -111,12 +111,10 @@ public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
return tableName;
}
else {
return new StringBuilder(ownerEntityTable).append("_")
.append(
associatedEntityTable != null ?
associatedEntityTable :
StringHelper.unqualify( propertyName )
).toString();
String entityTableName = associatedEntityTable != null
? associatedEntityTable
: StringHelper.unqualify(propertyName);
return ownerEntityTable + "_" + entityTableName;
}
}
/**

View File

@ -38,14 +38,10 @@ public class PersistenceStandardNamingStrategy implements NamingStrategy, Serial
String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
String propertyName
) {
return tableName(
new StringBuilder( ownerEntityTable ).append( "_" )
.append(
associatedEntityTable != null ?
associatedEntityTable :
StringHelper.unqualify( propertyName )
).toString()
);
String entityTableName = associatedEntityTable != null
? associatedEntityTable
: StringHelper.unqualify(propertyName);
return tableName( ownerEntityTable + "_" + entityTableName );
}
public String joinKeyColumnName(String joinedColumn, String joinedTable) {
@ -72,12 +68,10 @@ public class PersistenceStandardNamingStrategy implements NamingStrategy, Serial
return tableName;
}
else {
return new StringBuilder( ownerEntityTable ).append( "_" )
.append(
associatedEntityTable != null ?
associatedEntityTable :
StringHelper.unqualify( propertyName )
).toString();
String entityTableName = associatedEntityTable != null
? associatedEntityTable
: StringHelper.unqualify(propertyName);
return ownerEntityTable + "_" + entityTableName;
}
}

View File

@ -28,12 +28,7 @@ public class PropertyInferredData implements PropertyData {
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "PropertyInferredData" );
sb.append( "{property=" ).append( property );
sb.append( ", declaringClass=" ).append( declaringClass );
sb.append( '}' );
return sb.toString();
return String.format( "PropertyInferredData{property=%s, declaringClass=%s}", property, declaringClass );
}
/**