improve jdoc of SQM enums

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-10-20 13:56:46 +02:00
parent ddca820f42
commit 5db7629382
7 changed files with 74 additions and 50 deletions

View File

@ -8,8 +8,8 @@ package org.hibernate.query.sqm;
* Defines the set of basic types which should be * Defines the set of basic types which should be
* accepted by the {@code cast()} function on every * accepted by the {@code cast()} function on every
* platform. * platform.
* <p> *
* Note that while almost every database supports * @implNote While almost every database supports
* the ANSI {@code cast()} function, the actual type * the ANSI {@code cast()} function, the actual type
* conversions supported vary widely. Therefore, it * conversions supported vary widely. Therefore, it
* is sometimes necessary to emulate certain type * is sometimes necessary to emulate certain type
@ -19,6 +19,11 @@ package org.hibernate.query.sqm;
* type, and so type conversions to and from * type, and so type conversions to and from
* {@link Boolean} must be emulated. * {@link Boolean} must be emulated.
* *
* @apiNote This is an SPI type allowing collaboration
* between {@code org.hibernate.dialect} and
* {@code org.hibernate.sqm}. It should never occur in
* APIs visible to the application program.
*
* @see org.hibernate.dialect.Dialect#castPattern(CastType, CastType) * @see org.hibernate.dialect.Dialect#castPattern(CastType, CastType)
* *
* @author Gavin King * @author Gavin King
@ -33,16 +38,9 @@ public enum CastType {
OTHER; OTHER;
public boolean isNumeric() { public boolean isNumeric() {
switch (this) { return switch ( this ) {
case INTEGER: case INTEGER, LONG, INTEGER_BOOLEAN, FLOAT, DOUBLE, FIXED -> true;
case LONG: default -> false;
case INTEGER_BOOLEAN: };
case FLOAT:
case DOUBLE:
case FIXED:
return true;
default:
return false;
}
} }
} }

View File

@ -5,8 +5,12 @@
package org.hibernate.query.sqm; package org.hibernate.query.sqm;
/** /**
* Defines the comparison operators. We could also get away with * Enumerates the binary comparison operators.
* only 3 and use negation... *
* @apiNote This is an SPI type allowing collaboration
* between {@code org.hibernate.dialect} and
* {@code org.hibernate.sqm}. It should never occur in
* APIs visible to the application program.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */

View File

@ -10,6 +10,8 @@ import java.util.Map;
/** /**
* Represents the type of instantiation to be performed. * Represents the type of instantiation to be performed.
* *
* @see org.hibernate.query.sqm.tree.select.SqmDynamicInstantiationTarget#getNature
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public enum DynamicInstantiationNature { public enum DynamicInstantiationNature {

View File

@ -7,41 +7,45 @@ package org.hibernate.query.sqm;
/** /**
* The SQL set operators. * The SQL set operators.
* *
* @apiNote This is an SPI type. It should never occur
* in APIs visible to the application program.
*
* @author Christian Beikov * @author Christian Beikov
*/ */
public enum SetOperator { public enum SetOperator {
/** /**
* Union of sets that removes duplicate rows. * Union of sets that removes duplicate rows.
*/ */
UNION("union"), UNION,
/** /**
* Union of bags that retains all elements. * Union of bags that retains all elements.
*/ */
UNION_ALL("union all"), UNION_ALL,
/** /**
* Intersection of sets that removes duplicate rows. * Intersection of sets that removes duplicate rows.
*/ */
INTERSECT("intersect"), INTERSECT,
/** /**
* Intersection of bags that retains duplicate matches. * Intersection of bags that retains duplicate matches.
*/ */
INTERSECT_ALL("intersect all"), INTERSECT_ALL,
/** /**
* Exclusion of set elements of the set on the right-hand side. * Exclusion of set elements of the set on the right-hand side.
*/ */
EXCEPT("except"), EXCEPT,
/** /**
* Exclusion of bag elements of the bag on the right-hand side that retains duplicates. * Exclusion of bag elements of the bag on the right-hand side that retains duplicates.
*/ */
EXCEPT_ALL("except all"); EXCEPT_ALL;
private final String sqlString;
private SetOperator(String sqlString) {
this.sqlString = sqlString;
}
public String sqlString() { public String sqlString() {
return sqlString; return switch (this) {
case UNION -> "union";
case UNION_ALL -> "union all";
case INTERSECT -> "intersect";
case INTERSECT_ALL -> "intersect all";
case EXCEPT -> "except";
case EXCEPT_ALL -> "except all";
};
} }
} }

View File

@ -5,14 +5,25 @@
package org.hibernate.query.sqm; package org.hibernate.query.sqm;
/** /**
* Informational - used to identify the source of an SQM statement. * Identifies the source of an SQM statement.
* *
* @see org.hibernate.query.sqm.tree.SqmStatement#getQuerySource * @see org.hibernate.query.sqm.tree.SqmStatement#getQuerySource
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public enum SqmQuerySource { public enum SqmQuerySource {
/**
* The SQM tree represents a query written in HQL or JPQL.
*/
HQL, HQL,
/**
* The SQM tree was built via the
* {@linkplain org.hibernate.query.criteria.HibernateCriteriaBuilder
* criteria query API}.
*/
CRITERIA, CRITERIA,
/**
* The SQM tree came from somewhere else.
*/
OTHER OTHER
} }

View File

@ -5,11 +5,17 @@
package org.hibernate.query.sqm; package org.hibernate.query.sqm;
import jakarta.persistence.criteria.CriteriaBuilder; import jakarta.persistence.criteria.CriteriaBuilder;
import org.hibernate.AssertionFailure;
import java.util.Locale; import java.util.Locale;
/** /**
* Variations of the {@code trim()} function.
*
* @apiNote This is an SPI type allowing collaboration
* between {@code org.hibernate.dialect} and
* {@code org.hibernate.sqm}. It should never occur in
* APIs visible to the application program.
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public enum TrimSpec { public enum TrimSpec {
@ -21,17 +27,12 @@ public enum TrimSpec {
if ( jpaTs == null ) { if ( jpaTs == null ) {
return null; return null;
} }
else {
switch ( jpaTs ) { return switch ( jpaTs ) {
case BOTH: case BOTH -> BOTH;
return BOTH; case LEADING -> LEADING;
case LEADING: case TRAILING -> TRAILING;
return LEADING; };
case TRAILING:
return TRAILING;
default:
throw new AssertionFailure( "Unrecognized JPA TrimSpec" );
} }
} }

View File

@ -5,19 +5,23 @@
package org.hibernate.query.sqm; package org.hibernate.query.sqm;
/** /**
* Enumerates the unary prefix operators.
*
* @apiNote This is an SPI type allowing collaboration
* between {@code org.hibernate.dialect} and
* {@code org.hibernate.sqm}. It should never occur in
* APIs visible to the application program.
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public enum UnaryArithmeticOperator { public enum UnaryArithmeticOperator {
UNARY_PLUS( '+' ), UNARY_PLUS,
UNARY_MINUS( '-' ); UNARY_MINUS;
private final char operatorChar;
UnaryArithmeticOperator(char operatorChar) {
this.operatorChar = operatorChar;
}
public char getOperatorChar() { public char getOperatorChar() {
return operatorChar; return switch ( this ) {
case UNARY_PLUS -> '+';
case UNARY_MINUS -> '-';
};
} }
} }