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

View File

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

View File

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

View File

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