Skip to content

Commit 1b818b1

Browse files
committed
use 'var' in AbstractInformationExtractorImpl
1 parent 61f9f9a commit 1b818b1

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

hibernate-core/src/main/java/org/hibernate/tool/schema/extract/internal/AbstractInformationExtractorImpl.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,12 @@ protected NameSpacePrimaryKeysInformation extractNameSpacePrimaryKeysInformation
10241024
final String currentPkName = resultSet.getString( getResultSetPrimaryKeyNameLabel() );
10251025
final Identifier currentPrimaryKeyIdentifier =
10261026
currentPkName == null ? null : toIdentifier( currentPkName );
1027-
final TableInformation tableInformation = getTableInformation(
1027+
final var tableInformation = getTableInformation(
10281028
resultSet.getString( getResultSetPrimaryKeyCatalogLabel() ),
10291029
resultSet.getString( getResultSetPrimaryKeySchemaLabel() ),
10301030
currentTableName
10311031
);
1032-
PrimaryKeyInformation primaryKeyInformation =
1032+
var primaryKeyInformation =
10331033
primaryKeysInformation.getPrimaryKeyInformation( currentTableName );
10341034
final List<ColumnInformation> columns;
10351035
if ( primaryKeyInformation != null ) {
@@ -1162,7 +1162,7 @@ public Iterable<IndexInformation> getIndexes(TableInformation tableInformation)
11621162
!= DatabaseMetaData.tableIndexStatistic ) {
11631163
final Identifier indexIdentifier =
11641164
toIdentifier( resultSet.getString( getResultSetIndexNameLabel() ) );
1165-
var builder = indexInformationBuilder( builders, indexIdentifier );
1165+
final var builder = indexInformationBuilder( builders, indexIdentifier );
11661166
final Identifier columnIdentifier =
11671167
toIdentifier( resultSet.getString( getResultSetColumnNameLabel() ) );
11681168
final var columnInformation = tableInformation.getColumn( columnIdentifier );
@@ -1199,12 +1199,15 @@ public Iterable<IndexInformation> getIndexes(TableInformation tableInformation)
11991199
private static IndexInformationImpl.Builder indexInformationBuilder(
12001200
Map<Identifier, IndexInformationImpl.Builder> builders,
12011201
Identifier indexIdentifier) {
1202-
var builder = builders.get( indexIdentifier );
1202+
final var builder = builders.get( indexIdentifier );
12031203
if ( builder == null ) {
1204-
builder = IndexInformationImpl.builder( indexIdentifier );
1205-
builders.put( indexIdentifier, builder );
1204+
final var newBuilder = IndexInformationImpl.builder( indexIdentifier );
1205+
builders.put( indexIdentifier, newBuilder );
1206+
return newBuilder;
1207+
}
1208+
else {
1209+
return builder;
12061210
}
1207-
return builder;
12081211
}
12091212

12101213
@Override
@@ -1238,7 +1241,7 @@ protected NameSpaceIndexesInformation extractNameSpaceIndexesInformation(ResultS
12381241
while ( resultSet.next() ) {
12391242
if ( resultSet.getShort( getResultSetIndexTypeLabel() )
12401243
!= DatabaseMetaData.tableIndexStatistic ) {
1241-
final TableInformation tableInformation = getTableInformation(
1244+
final var tableInformation = getTableInformation(
12421245
resultSet.getString( getResultSetCatalogLabel() ),
12431246
resultSet.getString( getResultSetSchemaLabel() ),
12441247
resultSet.getString( getResultSetTableNameLabel() )
@@ -1266,10 +1269,10 @@ private IndexInformation getOrCreateIndexInformation(
12661269
NameSpaceIndexesInformation indexesInformation,
12671270
Identifier indexIdentifier,
12681271
TableInformation tableInformation) {
1269-
final List<IndexInformation> indexes =
1272+
final var indexes =
12701273
indexesInformation.getIndexesInformation( tableInformation.getName().getTableName().getText() );
12711274
if ( indexes != null ) {
1272-
for ( IndexInformation index : indexes ) {
1275+
for ( var index : indexes ) {
12731276
if ( indexIdentifier.equals( index.getIndexIdentifier() ) ) {
12741277
return index;
12751278
}
@@ -1515,7 +1518,7 @@ protected NameSpaceForeignKeysInformation extractNameSpaceForeignKeysInformation
15151518
final var foreignKeysInformation = new NameSpaceForeignKeysInformation( getIdentifierHelper() );
15161519

15171520
while ( resultSet.next() ) {
1518-
final TableInformation tableInformation = getTableInformation(
1521+
final var tableInformation = getTableInformation(
15191522
resultSet.getString( getResultSetForeignKeyCatalogLabel() ),
15201523
resultSet.getString( getResultSetForeignKeySchemaLabel() ),
15211524
resultSet.getString( getResultSetForeignKeyTableLabel() )
@@ -1550,10 +1553,10 @@ private ForeignKeyInformation getOrCreateForeignKeyInformation(
15501553
NameSpaceForeignKeysInformation foreignKeysInformation,
15511554
Identifier foreignKeyIdentifier,
15521555
TableInformation tableInformation) {
1553-
final List<ForeignKeyInformation> foreignKeys =
1556+
final var foreignKeys =
15541557
foreignKeysInformation.getForeignKeysInformation( tableInformation.getName().getTableName().getText() );
15551558
if ( foreignKeys != null ) {
1556-
for ( ForeignKeyInformation foreignKey : foreignKeys ) {
1559+
for ( var foreignKey : foreignKeys ) {
15571560
if ( foreignKeyIdentifier.equals( foreignKey.getForeignKeyIdentifier() ) ) {
15581561
return foreignKey;
15591562
}

0 commit comments

Comments
 (0)