Skip to content

Commit

Permalink
squash diverse compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin King <gavin@hibernate.org>
  • Loading branch information
gavinking committed May 17, 2024
1 parent 4a03c0e commit f32c9e6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class BasicDotIdentifierConsumer implements DotIdentifierConsumer {
private final SqmCreationState creationState;

private StringBuilder pathSoFar = new StringBuilder();
private final StringBuilder pathSoFar = new StringBuilder();
private SemanticPathPart currentPart;

public BasicDotIdentifierConsumer(SqmCreationState creationState) {
Expand Down Expand Up @@ -94,9 +94,8 @@ public void consumeIdentifier(String identifier, boolean isBase, boolean isTermi

@Override
public void consumeTreat(String entityName, boolean isTerminal) {
final EntityDomainType<?> entityDomainType = creationState.getCreationContext().getJpaMetamodel()
.entity( entityName );
currentPart = ( (SqmPath) currentPart ).treatAs( entityDomainType );
final SqmPath<?> path = (SqmPath<?>) currentPart;
currentPart = path.treatAs( creationState.getCreationContext().getJpaMetamodel().entity( entityName ) );
}

protected void reset() {
Expand Down Expand Up @@ -184,7 +183,7 @@ public SemanticPathPart resolvePathPart(
if ( importableName != null ) {
final EntityDomainType<?> entityDomainType = jpaMetamodel.entity( importableName );
if ( entityDomainType != null ) {
return new SqmLiteralEntityType( entityDomainType, nodeBuilder );
return new SqmLiteralEntityType<>( entityDomainType, nodeBuilder );
}
}

Expand Down Expand Up @@ -222,14 +221,10 @@ public SemanticPathPart resolvePathPart(
.classForName( prefix );
if ( namedClass != null ) {
final Field referencedField = namedClass.getDeclaredField( terminal );
if ( referencedField != null ) {
final JavaType<?> fieldJtd =
jpaMetamodel
.getTypeConfiguration()
.getJavaTypeRegistry()
.getDescriptor( referencedField.getType() );
return new SqmFieldLiteral( referencedField, fieldJtd, nodeBuilder);
}
final JavaType<?> fieldJtd =
jpaMetamodel.getTypeConfiguration().getJavaTypeRegistry()
.getDescriptor( referencedField.getType() );
return new SqmFieldLiteral<>( referencedField, fieldJtd, nodeBuilder);
}
}
catch (Exception ignore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/
package org.hibernate.query.hql.internal;

import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Collection;
Expand Down Expand Up @@ -43,10 +42,10 @@
public class FullyQualifiedReflectivePathTerminal
extends FullyQualifiedReflectivePath
implements SqmExpression {
private final @Nullable SqmExpressible expressibleType;
private final @Nullable SqmExpressible<?> expressibleType;
private final SqmCreationState creationState;

private final Function<SemanticQueryWalker,?> handler;
private final Function<SemanticQueryWalker<?>,?> handler;

public FullyQualifiedReflectivePathTerminal(
FullyQualifiedReflectivePathSource pathSource,
Expand All @@ -66,8 +65,7 @@ public FullyQualifiedReflectivePathTerminal copy(SqmCopyContext context) {
return this;
}

@SuppressWarnings("unchecked")
private Function<SemanticQueryWalker, ?> resolveTerminalSemantic() {
private Function<SemanticQueryWalker<?>, ?> resolveTerminalSemantic() {
return semanticQueryWalker -> {
final SqmCreationContext creationContext = creationState.getCreationContext();
final ClassLoaderService cls =
Expand Down Expand Up @@ -138,7 +136,7 @@ private JavaTypeRegistry javaTypeRegistry() {
}

@Override
public @Nullable SqmExpressible getNodeType() {
public @Nullable SqmExpressible<?> getNodeType() {
return expressibleType;
}

Expand All @@ -148,7 +146,7 @@ public Object accept(SemanticQueryWalker walker) {
}

@Override
public JavaType getJavaTypeDescriptor() {
public JavaType<?> getJavaTypeDescriptor() {
return expressibleType == null ? null : expressibleType.getExpressibleJavaType();
}

Expand Down Expand Up @@ -200,7 +198,7 @@ public SqmExpression<String> asString() {
}

@Override
public SqmExpression as(Class type) {
public SqmExpression<?> as(Class type) {
return null;
}

Expand Down Expand Up @@ -250,7 +248,7 @@ public List<? extends JpaSelection<?>> getSelectionItems() {
}

@Override
public JpaSelection alias(String name) {
public JpaSelection<?> alias(String name) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ protected void logUseOfReservedWordAsIdentifier(Token token) {
}
};
}

public HqlParser buildHqlParser(String hql) {
// Build the lexer
return buildHqlParser( hql, buildHqlLexer( hql ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,15 @@
import org.hibernate.query.sqm.spi.NamedSqmQueryMemento;
import org.hibernate.query.sqm.tree.SqmStatement;

import org.jboss.logging.Logger;

/**
* Definition of a named query, defined in the mapping metadata.
*
* Additionally, as of JPA 2.1, named query definition can also come
* from a compiled query.
*
* @author Gavin King
* @author Steve Ebersole
*/
public class NamedHqlQueryMementoImpl extends AbstractNamedQueryMemento implements NamedSqmQueryMemento, Serializable {
private static final Logger log = Logger.getLogger( NamedHqlQueryMementoImpl.class );

private final String hqlString;

private final Integer firstResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@
import org.hibernate.query.sqm.tree.update.SqmAssignment;
import org.hibernate.query.sqm.tree.update.SqmSetClause;
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
import org.hibernate.sql.ast.spi.SqlAstQueryPartProcessingState;
import org.hibernate.sql.ast.tree.from.TableGroup;

/**
* Base support for an SQM walker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,10 @@
import org.hibernate.sql.ast.tree.from.CorrelatedTableGroup;
import org.hibernate.sql.ast.tree.from.EmbeddableFunctionTableGroup;
import org.hibernate.sql.ast.tree.from.FromClause;
import org.hibernate.sql.ast.tree.from.FunctionTableGroup;
import org.hibernate.sql.ast.tree.from.NamedTableReference;
import org.hibernate.sql.ast.tree.from.PluralTableGroup;
import org.hibernate.sql.ast.tree.from.QueryPartTableGroup;
import org.hibernate.sql.ast.tree.from.QueryPartTableReference;
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
import org.hibernate.query.sqm.tree.select.SqmSelectableNode;

/**
* Represents an reference to an entity type as a literal. This is the JPA
* terminology for cases when we have something like: {@code ... where TYPE(e) = SomeType}.
* The token {@code SomeType} is an "entity type literal".
*
* An entity type expression can be used to restrict query polymorphism. The TYPE operator returns the exact type of the argument.
* Represents a reference to an entity type as a literal.
* In a restriction like {@code where TYPE(e) = SomeType},
* the token {@code SomeType} is used to restrict query
* polymorphism. The {@code TYPE} operator returns the
* exact concrete type of the argument.
*
* @author Steve Ebersole
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
*/
package org.hibernate.query.sqm.tree.predicate;

import org.hibernate.query.SemanticException;
import org.hibernate.query.sqm.ComparisonOperator;
import org.hibernate.query.internal.QueryHelper;
import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.tree.SqmCopyContext;
import org.hibernate.query.sqm.tree.domain.SqmPluralValuedSimplePath;
import org.hibernate.query.sqm.tree.expression.SqmExpression;

import static org.hibernate.query.sqm.internal.TypecheckUtil.assertComparable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
import java.sql.Types;

import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.ValueBinder;
import org.hibernate.type.descriptor.ValueExtractor;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.BasicJavaType;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.internal.JdbcLiteralFormatterCharacterData;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
Expand Down Expand Up @@ -63,8 +61,7 @@ public <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(

@Override
public <T> JdbcLiteralFormatter<T> getJdbcLiteralFormatter(JavaType<T> javaType) {
//noinspection unchecked
return new JdbcLiteralFormatterCharacterData( javaType, true );
return new JdbcLiteralFormatterCharacterData<>( javaType, true );
}

@Override
Expand Down

0 comments on commit f32c9e6

Please sign in to comment.