Interface PojoTypeModel<T>
- Type Parameters:
T
- The pojo type
- All Known Subinterfaces:
PojoRawTypeModel<T>
- All Known Implementing Classes:
AbstractPojoGenericTypeModel
,AbstractPojoHCAnnRawTypeModel
,AbstractPojoRawTypeModel
,GenericContextAwarePojoGenericTypeModel
,PojoSimpleHCAnnRawTypeModel
,SyntheticPojoGenericTypeModel
public interface PojoTypeModel<T>
A model representing a POJO type: its structure (properties and their type),
its name, ...
Most of the time, type models represent a Java class,
either raw
or parameterized
.
However, it is also possible that a given type model
represents a subset of all instances of a given Java class,
which all follow a common convention regarding their structure.
For example, a type model could represent a Map-based type
where properties are defined by the map entries
and where all instances are required to have a value of type Integer
for the key "age"
.
-
Method Summary
Modifier and TypeMethodDescriptionOptional<? extends PojoTypeModel<?>>
<U> Optional<PojoTypeModel<? extends U>>
boolean
int
hashCode()
name()
PojoRawTypeModel<? super T>
rawType()
toString()
Optional<? extends PojoTypeModel<?>>
typeArgument
(Class<?> rawSuperType, int typeParameterIndex)
-
Method Details
-
name
String name()- Returns:
- A human-readable name for this type.
-
rawType
PojoRawTypeModel<? super T> rawType()- Returns:
- A representation of the closest parent Java
Class
for this type.
-
property
- Parameters:
propertyName
- The name of aproperty
in this type.- Returns:
- A representation of the property with the given name.
- Throws:
SearchException
- If there is no property with the given name in this type.
-
castTo
- Type Parameters:
U
- The type to cast to.- Parameters:
target
- The type to cast to.- Returns:
- A new type model, representing the current type cast to the given type,
or
Optional.empty()
if casting is not supported. The type model will retain as much contextual type information as possible (type arguments, ...), so castingList<Integer>
toCollection
for example would returnCollection<Integer>
.
-
typeArgument
- Parameters:
rawSuperType
- The supertype to resolve type parameters fortypeParameterIndex
- The index of the type parameter to resolve- Returns:
- The model for the type argument for the type parameter defined in
rawSuperType
at indextypeParameterIndex
, or an empty optional if the current type does not extendrawSuperType
. Implementations may decide to return a model of the raw type argument, or to retain generics information.
-
arrayElementType
Optional<? extends PojoTypeModel<?>> arrayElementType()- Returns:
- The model for the array element type, or an empty optional if the current type is not an array type. Implementations may decide to return a model of the raw array element type, or to retain generics information.
-
toString
String toString() -
equals
- Overrides:
equals
in classObject
- Returns:
true
ifobj
is aPojoTypeModel
referencing the exact same type with the exact same exposed metadata.
-
hashCode
int hashCode()
-