squash some warnings by filling in <?>

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-10-20 13:59:30 +02:00
parent 5db7629382
commit 26efd4e530
5 changed files with 76 additions and 82 deletions

View File

@ -162,7 +162,7 @@ public interface SemanticQueryWalker<T> {
T visitRootDerived(SqmDerivedRoot<?> sqmRoot); T visitRootDerived(SqmDerivedRoot<?> sqmRoot);
T visitRootFunction(SqmFunctionRoot sqmRoot); T visitRootFunction(SqmFunctionRoot<?> sqmRoot);
T visitRootCte(SqmCteRoot<?> sqmRoot); T visitRootCte(SqmCteRoot<?> sqmRoot);

View File

@ -140,7 +140,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
private static final Logger LOGGER = QueryLogging.subLogger( "sqm.ast" ); private static final Logger LOGGER = QueryLogging.subLogger( "sqm.ast" );
private static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled(); private static final boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
public static void logTree(SqmQuerySpec sqmQuerySpec, String header) { public static void logTree(SqmQuerySpec<?> sqmQuerySpec, String header) {
if ( ! DEBUG_ENABLED ) { if ( ! DEBUG_ENABLED ) {
return; return;
} }
@ -154,24 +154,24 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
LOGGER.debugf( "%s :%n%s", title, treePrinter.buffer.toString() ); LOGGER.debugf( "%s :%n%s", title, treePrinter.buffer.toString() );
} }
public static void logTree(SqmStatement sqmStatement) { public static void logTree(SqmStatement<?> sqmStatement) {
if ( ! DEBUG_ENABLED ) { if ( ! DEBUG_ENABLED ) {
return; return;
} }
final SqmTreePrinter printer = new SqmTreePrinter(); final SqmTreePrinter printer = new SqmTreePrinter();
if ( sqmStatement instanceof SqmSelectStatement ) { if ( sqmStatement instanceof SqmSelectStatement<?> statement ) {
printer.visitSelectStatement( (SqmSelectStatement) sqmStatement ); printer.visitSelectStatement( statement );
} }
else if ( sqmStatement instanceof SqmDeleteStatement<?> ) { else if ( sqmStatement instanceof SqmDeleteStatement<?> statement ) {
printer.visitDeleteStatement( (SqmDeleteStatement) sqmStatement ); printer.visitDeleteStatement( statement );
} }
else if ( sqmStatement instanceof SqmUpdateStatement ) { else if ( sqmStatement instanceof SqmUpdateStatement<?> statement ) {
printer.visitUpdateStatement( (SqmUpdateStatement) sqmStatement ); printer.visitUpdateStatement( statement );
} }
else if ( sqmStatement instanceof SqmInsertSelectStatement ) { else if ( sqmStatement instanceof SqmInsertSelectStatement<?> statement ) {
printer.visitInsertSelectStatement( (SqmInsertSelectStatement) sqmStatement ); printer.visitInsertSelectStatement( statement );
} }
LOGGER.debugf( "SqmStatement Tree :%n%s", printer.buffer.toString() ); LOGGER.debugf( "SqmStatement Tree :%n%s", printer.buffer.toString() );
@ -386,7 +386,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitCteStatement(SqmCteStatement sqmCteStatement) { public Object visitCteStatement(SqmCteStatement<?> sqmCteStatement) {
if ( DEBUG_ENABLED ) { if ( DEBUG_ENABLED ) {
logIndented( "cte" ); logIndented( "cte" );
} }
@ -536,7 +536,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitRootPath(SqmRoot sqmRoot) { public Object visitRootPath(SqmRoot<?> sqmRoot) {
processStanza( processStanza(
"root", "root",
"`" + sqmRoot.getNavigablePath() + "`", "`" + sqmRoot.getNavigablePath() + "`",
@ -551,21 +551,17 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
processStanza( processStanza(
"derived", "derived",
"`" + sqmRoot.getNavigablePath() + "`", "`" + sqmRoot.getNavigablePath() + "`",
() -> { () -> processJoins( sqmRoot )
processJoins( sqmRoot );
}
); );
return null; return null;
} }
@Override @Override
public Object visitRootFunction(SqmFunctionRoot sqmRoot) { public Object visitRootFunction(SqmFunctionRoot<?> sqmRoot) {
processStanza( processStanza(
"derived", "derived",
"`" + sqmRoot.getNavigablePath() + "`", "`" + sqmRoot.getNavigablePath() + "`",
() -> { () -> processJoins( sqmRoot )
processJoins( sqmRoot );
}
); );
return null; return null;
} }
@ -575,9 +571,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
processStanza( processStanza(
"cte", "cte",
"`" + sqmRoot.getNavigablePath() + "`", "`" + sqmRoot.getNavigablePath() + "`",
() -> { () -> processJoins( sqmRoot )
processJoins( sqmRoot );
}
); );
return null; return null;
} }
@ -594,7 +588,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitCrossJoin(SqmCrossJoin joinedFromElement) { public Object visitCrossJoin(SqmCrossJoin<?> joinedFromElement) {
processStanza( processStanza(
"cross", "cross",
"`" + joinedFromElement.getNavigablePath() + "`", "`" + joinedFromElement.getNavigablePath() + "`",
@ -630,7 +624,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitQualifiedEntityJoin(SqmEntityJoin joinedFromElement) { public Object visitQualifiedEntityJoin(SqmEntityJoin<?,?> joinedFromElement) {
if ( inJoinPredicate ) { if ( inJoinPredicate ) {
logWithIndentation( "-> [joined-path] - `%s`", joinedFromElement.getNavigablePath() ); logWithIndentation( "-> [joined-path] - `%s`", joinedFromElement.getNavigablePath() );
} }
@ -648,7 +642,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitQualifiedAttributeJoin(SqmAttributeJoin joinedFromElement) { public Object visitQualifiedAttributeJoin(SqmAttributeJoin<?,?> joinedFromElement) {
if ( inJoinPredicate ) { if ( inJoinPredicate ) {
logWithIndentation( "-> [joined-path] - `%s`", joinedFromElement.getNavigablePath() ); logWithIndentation( "-> [joined-path] - `%s`", joinedFromElement.getNavigablePath() );
} }
@ -722,14 +716,14 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitBasicValuedPath(SqmBasicValuedSimplePath path) { public Object visitBasicValuedPath(SqmBasicValuedSimplePath<?> path) {
logWithIndentation( "-> [basic-path] - `%s`", path.getNavigablePath() ); logWithIndentation( "-> [basic-path] - `%s`", path.getNavigablePath() );
return null; return null;
} }
@Override @Override
public Object visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath path) { public Object visitEmbeddableValuedPath(SqmEmbeddedValuedSimplePath<?> path) {
logWithIndentation( "-> [embedded-path] - `%s`", path.getNavigablePath() ); logWithIndentation( "-> [embedded-path] - `%s`", path.getNavigablePath() );
return null; return null;
@ -764,14 +758,14 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitEntityValuedPath(SqmEntityValuedSimplePath path) { public Object visitEntityValuedPath(SqmEntityValuedSimplePath<?> path) {
logWithIndentation( "-> [entity-path] - `%s`", path.getNavigablePath() ); logWithIndentation( "-> [entity-path] - `%s`", path.getNavigablePath() );
return null; return null;
} }
@Override @Override
public Object visitPluralValuedPath(SqmPluralValuedSimplePath path) { public Object visitPluralValuedPath(SqmPluralValuedSimplePath<?> path) {
logWithIndentation( "-> [plural-path] - `%s`", path.getNavigablePath() ); logWithIndentation( "-> [plural-path] - `%s`", path.getNavigablePath() );
return null; return null;
@ -783,7 +777,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitTreatedPath(SqmTreatedPath sqmTreatedPath) { public Object visitTreatedPath(SqmTreatedPath<?,?> sqmTreatedPath) {
return null; return null;
} }
@ -803,7 +797,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitSelection(SqmSelection selection) { public Object visitSelection(SqmSelection<?> selection) {
processStanza( processStanza(
selection.getAlias() == null ? "selection" : "selection(" + selection.getAlias() + ")", selection.getAlias() == null ? "selection" : "selection(" + selection.getAlias() + ")",
() -> selection.getSelectableNode().accept( this ) () -> selection.getSelectableNode().accept( this )
@ -818,26 +812,26 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitPositionalParameterExpression(SqmPositionalParameter expression) { public Object visitPositionalParameterExpression(SqmPositionalParameter<?> expression) {
logWithIndentation( "?%s", expression.getPosition() ); logWithIndentation( "?%s", expression.getPosition() );
return null; return null;
} }
@Override @Override
public Object visitNamedParameterExpression(SqmNamedParameter expression) { public Object visitNamedParameterExpression(SqmNamedParameter<?> expression) {
logWithIndentation( ":%s", expression.getName() ); logWithIndentation( ":%s", expression.getName() );
return null; return null;
} }
@Override @Override
public Object visitJpaCriteriaParameter(JpaCriteriaParameter expression) { public Object visitJpaCriteriaParameter(JpaCriteriaParameter<?> expression) {
return null; return null;
} }
@Override @Override
public Object visitEntityTypeLiteralExpression(SqmLiteralEntityType expression) { public Object visitEntityTypeLiteralExpression(SqmLiteralEntityType<?> expression) {
return null; return null;
} }
@ -847,12 +841,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitParameterizedEntityTypeExpression(SqmParameterizedEntityType expression) { public Object visitParameterizedEntityTypeExpression(SqmParameterizedEntityType<?> expression) {
return null; return null;
} }
@Override @Override
public Object visitUnaryOperationExpression(SqmUnaryOperation expression) { public Object visitUnaryOperationExpression(SqmUnaryOperation<?> expression) {
return null; return null;
} }
@ -1066,12 +1060,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitInListPredicate(SqmInListPredicate predicate) { public Object visitInListPredicate(SqmInListPredicate<?> predicate) {
return null; return null;
} }
@Override @Override
public Object visitInSubQueryPredicate(SqmInSubQueryPredicate predicate) { public Object visitInSubQueryPredicate(SqmInSubQueryPredicate<?> predicate) {
return null; return null;
} }
@ -1096,12 +1090,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitOffsetExpression(SqmExpression expression) { public Object visitOffsetExpression(SqmExpression<?> expression) {
return null; return null;
} }
@Override @Override
public Object visitFetchExpression(SqmExpression expression) { public Object visitFetchExpression(SqmExpression<?> expression) {
return null; return null;
} }
@ -1116,12 +1110,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitElementAggregateFunction(SqmElementAggregateFunction binding) { public Object visitElementAggregateFunction(SqmElementAggregateFunction<?> binding) {
return null; return null;
} }
@Override @Override
public Object visitIndexAggregateFunction(SqmIndexAggregateFunction path) { public Object visitIndexAggregateFunction(SqmIndexAggregateFunction<?> path) {
return null; return null;
} }
@ -1131,12 +1125,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitLiteral(SqmLiteral literal) { public Object visitLiteral(SqmLiteral<?> literal) {
return null; return null;
} }
@Override @Override
public Object visitTuple(SqmTuple sqmTuple) { public Object visitTuple(SqmTuple<?> sqmTuple) {
return null; return null;
} }
@ -1146,22 +1140,22 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitBinaryArithmeticExpression(SqmBinaryArithmetic expression) { public Object visitBinaryArithmeticExpression(SqmBinaryArithmetic<?> expression) {
return null; return null;
} }
@Override @Override
public Object visitSubQueryExpression(SqmSubQuery expression) { public Object visitSubQueryExpression(SqmSubQuery<?> expression) {
return null; return null;
} }
@Override @Override
public Object visitSimpleCaseExpression(SqmCaseSimple expression) { public Object visitSimpleCaseExpression(SqmCaseSimple<?,?> expression) {
return null; return null;
} }
@Override @Override
public Object visitSearchedCaseExpression(SqmCaseSearched expression) { public Object visitSearchedCaseExpression(SqmCaseSearched<?> expression) {
return null; return null;
} }
@ -1191,12 +1185,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitDynamicInstantiation(SqmDynamicInstantiation sqmDynamicInstantiation) { public Object visitDynamicInstantiation(SqmDynamicInstantiation<?> sqmDynamicInstantiation) {
processStanza( processStanza(
"dynamic-instantiation (" + sqmDynamicInstantiation.getInstantiationTarget().getJavaType() + ')', "dynamic-instantiation (" + sqmDynamicInstantiation.getInstantiationTarget().getJavaType() + ')',
() -> processStanza( () -> processStanza(
"arguments", "arguments",
() -> ( (SqmDynamicInstantiation<?>) sqmDynamicInstantiation ).getArguments().forEach( () -> sqmDynamicInstantiation.getArguments().forEach(
argument -> processStanza( argument -> processStanza(
"argument (" + argument.getAlias() + ')', "argument (" + argument.getAlias() + ')',
() -> { () -> {
@ -1228,12 +1222,12 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitFullyQualifiedClass(Class namedClass) { public Object visitFullyQualifiedClass(Class<?> namedClass) {
return null; return null;
} }
@Override @Override
public Object visitAsWrapperExpression(AsWrapperSqmExpression expression) { public Object visitAsWrapperExpression(AsWrapperSqmExpression<?> expression) {
return null; return null;
} }
@ -1243,7 +1237,7 @@ public class SqmTreePrinter implements SemanticQueryWalker<Object> {
} }
@Override @Override
public Object visitModifiedSubQueryExpression(SqmModifiedSubQueryExpression expression) { public Object visitModifiedSubQueryExpression(SqmModifiedSubQueryExpression<?> expression) {
return null; return null;
} }
} }

View File

@ -6,6 +6,7 @@ package org.hibernate.query.sqm.spi;
import java.util.List; import java.util.List;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.model.domain.DiscriminatorSqmPath; import org.hibernate.metamodel.model.domain.DiscriminatorSqmPath;
import org.hibernate.metamodel.model.domain.internal.AnyDiscriminatorSqmPath; import org.hibernate.metamodel.model.domain.internal.AnyDiscriminatorSqmPath;
import org.hibernate.query.sqm.InterpretationException; import org.hibernate.query.sqm.InterpretationException;
@ -227,11 +228,14 @@ public abstract class BaseSemanticQueryWalker implements SemanticQueryWalker<Obj
} }
protected Object visitSelectQuery(SqmSelectQuery<?> selectQuery) { protected Object visitSelectQuery(SqmSelectQuery<?> selectQuery) {
if ( selectQuery instanceof SqmSelectStatement<?> ) { if ( selectQuery instanceof SqmSelectStatement<?> statement ) {
return visitSelectStatement( (SqmSelectStatement<?>) selectQuery ); return visitSelectStatement( statement );
}
else if ( selectQuery instanceof SqmSubQuery<?> subquery ) {
return visitSubQueryExpression( subquery );
} }
else { else {
return visitSubQueryExpression( (SqmSubQuery<?>) selectQuery ); throw new AssertionFailure( "Unrecognized SQM select query type" );
} }
} }
@ -297,11 +301,7 @@ public abstract class BaseSemanticQueryWalker implements SemanticQueryWalker<Obj
} }
protected void consumeExplicitJoins(SqmFrom<?, ?> sqmFrom) { protected void consumeExplicitJoins(SqmFrom<?, ?> sqmFrom) {
sqmFrom.visitSqmJoins( sqmFrom.visitSqmJoins( sqmJoin -> consumeExplicitJoin( sqmJoin, true ) );
sqmJoin -> {
consumeExplicitJoin( sqmJoin, true );
}
);
final List<SqmTreatedFrom<?,?,?>> sqmTreats = sqmFrom.getSqmTreats(); final List<SqmTreatedFrom<?,?,?>> sqmTreats = sqmFrom.getSqmTreats();
if ( !sqmTreats.isEmpty() ) { if ( !sqmTreats.isEmpty() ) {
for ( SqmFrom<?, ?> sqmTreat : sqmTreats ) { for ( SqmFrom<?, ?> sqmTreat : sqmTreats ) {
@ -317,26 +317,26 @@ public abstract class BaseSemanticQueryWalker implements SemanticQueryWalker<Obj
protected void consumeExplicitJoin( protected void consumeExplicitJoin(
SqmJoin<?, ?> sqmJoin, SqmJoin<?, ?> sqmJoin,
boolean transitive) { boolean transitive) {
if ( sqmJoin instanceof SqmAttributeJoin<?, ?> ) { if ( sqmJoin instanceof SqmAttributeJoin<?, ?> join ) {
consumeAttributeJoin( ( (SqmAttributeJoin<?, ?>) sqmJoin ), transitive ); consumeAttributeJoin( join, transitive );
} }
else if ( sqmJoin instanceof SqmCrossJoin<?> ) { else if ( sqmJoin instanceof SqmCrossJoin<?> crossJoin ) {
consumeCrossJoin( ( (SqmCrossJoin<?>) sqmJoin ), transitive ); consumeCrossJoin( crossJoin, transitive );
} }
else if ( sqmJoin instanceof SqmEntityJoin<?,?> ) { else if ( sqmJoin instanceof SqmEntityJoin<?,?> entityJoin ) {
consumeEntityJoin( ( (SqmEntityJoin<?,?>) sqmJoin ), transitive ); consumeEntityJoin( entityJoin, transitive );
} }
else if ( sqmJoin instanceof SqmDerivedJoin<?> ) { else if ( sqmJoin instanceof SqmDerivedJoin<?> derivedJoin ) {
consumeDerivedJoin( ( (SqmDerivedJoin<?>) sqmJoin ), transitive ); consumeDerivedJoin( derivedJoin, transitive );
} }
else if ( sqmJoin instanceof SqmFunctionJoin<?> ) { else if ( sqmJoin instanceof SqmFunctionJoin<?> functionJoin ) {
consumeFunctionJoin( (SqmFunctionJoin<?>) sqmJoin, transitive ); consumeFunctionJoin( functionJoin, transitive );
} }
else if ( sqmJoin instanceof SqmCteJoin<?> ) { else if ( sqmJoin instanceof SqmCteJoin<?> cteJoin ) {
consumeCteJoin( ( (SqmCteJoin<?>) sqmJoin ), transitive ); consumeCteJoin( cteJoin, transitive );
} }
else if ( sqmJoin instanceof SqmPluralPartJoin<?, ?> ) { else if ( sqmJoin instanceof SqmPluralPartJoin<?, ?> pluralPartJoin ) {
consumePluralPartJoin( ( (SqmPluralPartJoin<?, ?>) sqmJoin ), transitive ); consumePluralPartJoin( pluralPartJoin, transitive );
} }
else { else {
throw new InterpretationException( "Could not visit SqmJoin [" + sqmJoin.getNavigablePath() + "] of type [" + sqmJoin.getClass().getName() + "]" ); throw new InterpretationException( "Could not visit SqmJoin [" + sqmJoin.getNavigablePath() + "] of type [" + sqmJoin.getClass().getName() + "]" );
@ -416,7 +416,7 @@ public abstract class BaseSemanticQueryWalker implements SemanticQueryWalker<Obj
} }
@Override @Override
public Object visitRootFunction(SqmFunctionRoot sqmRoot) { public Object visitRootFunction(SqmFunctionRoot<?>sqmRoot) {
return sqmRoot; return sqmRoot;
} }

View File

@ -1686,7 +1686,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
targetJavaType = (Class<X>) Map.class; targetJavaType = (Class<X>) Map.class;
} }
else { else {
targetJavaType = instantiationTarget.getJavaType(); targetJavaType = (Class<X>) instantiationTarget.getJavaType();
} }
return getCreationContext().getMappingMetamodel() return getCreationContext().getMappingMetamodel()

View File

@ -33,7 +33,7 @@ public interface SqmDynamicInstantiationTarget<T> extends SqmExpressible<T> {
* *
* @return The type to be instantiated. * @return The type to be instantiated.
*/ */
default Class getJavaType() { default Class<?> getJavaType() {
return getTargetTypeDescriptor().getJavaTypeClass(); return getTargetTypeDescriptor().getJavaTypeClass();
} }
} }