Skip to content

Commit efc50aa

Browse files
committed
squash warnings
1 parent 600288d commit efc50aa

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

hibernate-core/src/main/java/org/hibernate/boot/query/HbmResultSetMappingDescriptor.java

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ public HbmResultSetMappingDescriptor(
107107
);
108108
}
109109

110-
if ( hbmValueMapping instanceof JaxbHbmNativeQueryReturnType ) {
111-
final JaxbHbmNativeQueryReturnType hbmEntityReturn = (JaxbHbmNativeQueryReturnType) hbmValueMapping;
112-
110+
if ( hbmValueMapping instanceof JaxbHbmNativeQueryReturnType hbmEntityReturn ) {
113111
final EntityResultDescriptor entityResultDescriptor = new EntityResultDescriptor(
114112
hbmEntityReturn,
115113
() -> joinDescriptors,
@@ -119,10 +117,8 @@ public HbmResultSetMappingDescriptor(
119117
localResultDescriptors.add( entityResultDescriptor );
120118
fetchParentByAlias.put( entityResultDescriptor.tableAlias, entityResultDescriptor );
121119
}
122-
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryCollectionLoadReturnType ) {
123-
final JaxbHbmNativeQueryCollectionLoadReturnType hbmCollectionReturn = (JaxbHbmNativeQueryCollectionLoadReturnType) hbmValueMapping;
120+
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryCollectionLoadReturnType hbmCollectionReturn ) {
124121
foundCollectionReturn = true;
125-
126122
final CollectionResultDescriptor collectionResultDescriptor = new CollectionResultDescriptor(
127123
hbmCollectionReturn,
128124
() -> joinDescriptors,
@@ -132,14 +128,10 @@ else if ( hbmValueMapping instanceof JaxbHbmNativeQueryCollectionLoadReturnType
132128
localResultDescriptors.add( collectionResultDescriptor );
133129
fetchParentByAlias.put( collectionResultDescriptor.tableAlias, collectionResultDescriptor );
134130
}
135-
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryJoinReturnType ) {
136-
final JaxbHbmNativeQueryJoinReturnType jaxbHbmJoinReturn = (JaxbHbmNativeQueryJoinReturnType) hbmValueMapping;
137-
131+
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryJoinReturnType jaxbHbmJoinReturn ) {
138132
collectJoinFetch( jaxbHbmJoinReturn, joinDescriptors, fetchParentByAlias, registrationName, context );
139133
}
140-
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryScalarReturnType ) {
141-
final JaxbHbmNativeQueryScalarReturnType hbmScalarReturn = (JaxbHbmNativeQueryScalarReturnType) hbmValueMapping;
142-
134+
else if ( hbmValueMapping instanceof JaxbHbmNativeQueryScalarReturnType hbmScalarReturn ) {
143135
localResultDescriptors.add( new ScalarDescriptor( hbmScalarReturn ) );
144136
}
145137
else {
@@ -510,7 +502,7 @@ public PropertyFetchDescriptor(
510502
this.parent = parent;
511503
this.propertyPath = hbmPropertyMapping.getName();
512504
this.propertyPathParts = StringHelper.split( ".", propertyPath );
513-
this.columnAliases = extractColumnAliases( hbmPropertyMapping, context );
505+
this.columnAliases = extractColumnAliases( hbmPropertyMapping );
514506

515507
if ( columnAliases.size() > 1 ) {
516508
// We have to reorder the columns according to the property reordering
@@ -536,11 +528,11 @@ public PropertyFetchDescriptor(
536528
}
537529

538530
private static Value getValue(HbmFetchParent parent, String propertyPath, MetadataBuildingContext context) {
539-
if ( parent instanceof EntityResultDescriptor ) {
531+
if ( parent instanceof EntityResultDescriptor resultDescriptor ) {
540532
final PersistentClass entityBinding = context.getMetadataCollector()
541-
.getEntityBinding( ( (EntityResultDescriptor) parent ).entityName );
533+
.getEntityBinding( resultDescriptor.entityName );
542534
Value value = null;
543-
StringTokenizer st = new StringTokenizer( propertyPath, ".", false );
535+
final StringTokenizer st = new StringTokenizer( propertyPath, ".", false );
544536
try {
545537
while ( st.hasMoreElements() ) {
546538
final String element = (String) st.nextElement();
@@ -569,17 +561,17 @@ else if ( identifierProperty == null && entityBinding.getIdentifierMapper() != n
569561
value = entityBinding.getProperty( element ).getValue();
570562
}
571563
}
572-
else if ( value instanceof Component ) {
573-
value = ( (Component) value ).getProperty( element ).getValue();
564+
else if ( value instanceof Component component ) {
565+
value = component.getProperty( element ).getValue();
574566
}
575-
else if ( value instanceof ToOne ) {
567+
else if ( value instanceof ToOne toOne ) {
576568
value = context.getMetadataCollector()
577-
.getEntityBinding( ( (ToOne) value ).getReferencedEntityName() )
569+
.getEntityBinding( toOne.getReferencedEntityName() )
578570
.getProperty( element )
579571
.getValue();
580572
}
581-
else if ( value instanceof OneToMany ) {
582-
value = ( (OneToMany) value ).getAssociatedClass().getProperty( element ).getValue();
573+
else if ( value instanceof OneToMany oneToMany ) {
574+
value = oneToMany.getAssociatedClass().getProperty( element ).getValue();
583575
}
584576
else {
585577
final Collection collection = (Collection) value;
@@ -606,9 +598,9 @@ else if ( value instanceof OneToMany ) {
606598
throw new MappingException( "property [" + propertyPath + "] not found on entity [" + entityBinding.getEntityName() + "]" );
607599
}
608600
}
609-
else if ( parent instanceof CollectionResultDescriptor ) {
601+
else if ( parent instanceof CollectionResultDescriptor descriptor ) {
610602
final Collection collectionBinding = context.getMetadataCollector()
611-
.getCollectionBinding( ( (CollectionResultDescriptor) parent ).collectionPath.getFullPath() );
603+
.getCollectionBinding( descriptor.collectionPath.getFullPath() );
612604
return collectionBinding.getElement();
613605
}
614606
else {
@@ -629,9 +621,7 @@ public List<String> getColumnAliases() {
629621
return columnAliases;
630622
}
631623

632-
private static List<String> extractColumnAliases(
633-
JaxbHbmNativeQueryPropertyReturnType hbmPropertyMapping,
634-
MetadataBuildingContext context) {
624+
private static List<String> extractColumnAliases(JaxbHbmNativeQueryPropertyReturnType hbmPropertyMapping) {
635625
if ( hbmPropertyMapping.getColumn() != null ) {
636626
return Collections.singletonList( hbmPropertyMapping.getColumn() );
637627
}
@@ -853,7 +843,6 @@ public ResultMemento asResultMemento(
853843
public static class CollectionResultDescriptor implements ResultDescriptor, HbmFetchParent {
854844
private final NavigablePath collectionPath;
855845
private final String tableAlias;
856-
private final LockMode lockMode;
857846
private final Supplier<Map<String, Map<String, JoinDescriptor>>> joinDescriptorsAccess;
858847
private final List<HbmFetchDescriptor> propertyFetchDescriptors;
859848

@@ -887,7 +876,7 @@ public CollectionResultDescriptor(
887876
collectionPath
888877
);
889878

890-
this.lockMode = hbmCollectionReturn.getLockMode();
879+
// this.lockMode = hbmCollectionReturn.getLockMode();
891880
this.joinDescriptorsAccess = joinDescriptorsAccess;
892881

893882
this.propertyFetchDescriptors = extractPropertyFetchDescriptors(

0 commit comments

Comments
 (0)