java.lang.Object
java.lang.Record
org.litebridge.orm.expression.intent.ConvertSpec<T>
- Type Parameters:
T- The target Java type for conversion.
- All Implemented Interfaces:
ExpressionSpec,Resolvable,TypeOverride<T>,TypeOverrideExpressionSpec<T>
public record ConvertSpec<T>(ExpressionSpec target, Class<T> returnType)
extends Record
implements TypeOverrideExpressionSpec<T>, Resolvable
Converts a database result into the specified Java type.
This uses Litebridge's registered type converter to perform the conversion; it is not a database operation.
-
Constructor Summary
ConstructorsConstructorDescriptionConvertSpec(ExpressionSpec target, Class<T> returnType) Constructs aConvertSpecwith the specified target expression and return type. -
Method Summary
Modifier and TypeMethodDescriptioncolumn()Returns the target column name for this expression.booleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.replaceTarget(ExpressionSpec resolvedExpressionSpec) Creates a newConvertSpecwith a replaced target expression.Returns the value of thereturnTyperecord component.target()Gets the target expression for conversion.final StringtoString()Returns a string representation of this record class.Class<? extends ExpressionSpec> type()Returns the type ofExpressionSpecthat thisResolvablecan resolve to.
-
Constructor Details
-
ConvertSpec
Constructs aConvertSpecwith the specified target expression and return type.- Parameters:
target- the target expression to convertreturnType- the class of the target Java type
-
-
Method Details
-
target
Gets the target expression for conversion.- Returns:
- the target expression
-
column
Description copied from interface:ResolvableReturns the target column name for this expression.- Specified by:
columnin interfaceResolvable- Returns:
- the target column name.
-
type
Description copied from interface:ResolvableReturns the type ofExpressionSpecthat thisResolvablecan resolve to.- Specified by:
typein interfaceResolvable- Returns:
- the type of
ExpressionSpecthat thisResolvablecan resolve to.
-
replaceTarget
Creates a newConvertSpecwith a replaced target expression.- Parameters:
resolvedExpressionSpec- the new target expression- Returns:
- a new
ConvertSpecinstance
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
returnType
Returns the value of thereturnTyperecord component.- Specified by:
returnTypein interfaceTypeOverride<T>- Returns:
- the value of the
returnTyperecord component
-