Class MethodReturn
java.lang.Object
org.springframework.data.repository.aot.generate.MethodReturn
Value object that encapsulates introspection of a method's return type, providing convenient access to its
characteristics such as projection, optionality, array status, and actual type information.
Designed to support repository method analysis in the context of Ahead-of-Time (AOT) processing, this class leverages
ReturnedType, ResolvableType, and TypeInformation to expose both the declared and actual
return types, including handling of wrapper types, projections, and primitive types.
Typical usage involves querying the return type characteristics to drive code generation or runtime behavior in repository infrastructure.
- Since:
- 4.0
- Author:
- Mark Paluch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.javapoet.TypeNameReturns the actualTypeNamerepresenting the declared return class (component type of collections).Class<?> Returns theClassrepresenting the actual return type.Returns the actual type (i.e. collection component type).org.springframework.javapoet.TypeNameReturns the actualTypeNamerepresenting the declared return type (component type of collections).org.springframework.javapoet.TypeNameReturns theTypeNamerepresenting the declared return class (i.e. without generics).org.springframework.javapoet.TypeNameReturns theTypeNamerepresenting the declared return type.booleanisArray()Returns whether the method return type is an array.booleanReturns whether the method return type is an interface-based projection.booleanReturns whether the method return type isOptional.booleanReturns whether the method return type is a projection.booleanisVoid()Returns whether the method return type isvoid.Class<?> toClass()Returns theClassrepresenting the declared return type.
-
Constructor Details
-
MethodReturn
- Parameters:
returnedType- the returned type to inspect.returnType- the method return type.
-
-
Method Details
-
isProjecting
public boolean isProjecting()Returns whether the method return type is a projection. Query projections (e.g. returningStringorintare not considered.- Returns:
- true if the return type is a projection.
-
isInterfaceProjection
public boolean isInterfaceProjection()Returns whether the method return type is an interface-based projection.- Returns:
- true if the return type is an interface-based projection.
-
isOptional
public boolean isOptional()Returns whether the method return type isOptional.- Returns:
- true if the return type is
Optional.
-
isArray
public boolean isArray()Returns whether the method return type is an array.- Returns:
- true if the return type is an array.
-
isVoid
public boolean isVoid()- Returns:
- true if the return type is
void.
-
toClass
-
getActualType
Returns the actual type (i.e. collection component type).- Returns:
- the actual type.
-
getTypeName
public org.springframework.javapoet.TypeName getTypeName()Returns theTypeNamerepresenting the declared return type.- Returns:
- the declared return type name.
-
getClassName
public org.springframework.javapoet.TypeName getClassName()Returns theTypeNamerepresenting the declared return class (i.e. without generics).- Returns:
- the declared return class name.
-
getActualTypeName
public org.springframework.javapoet.TypeName getActualTypeName()Returns the actualTypeNamerepresenting the declared return type (component type of collections).- Returns:
- the actual return type name.
-
getActualClassName
public org.springframework.javapoet.TypeName getActualClassName()Returns the actualTypeNamerepresenting the declared return class (component type of collections).- Returns:
- the actual return class name.
-
getActualReturnClass
-