public class EndpointTransferMapper extends Object
Each endpoint parameter value coming from the client is passed through a registered mapper for that endpoint type before the values are passed to the endpoint methods.
Each endpoint return value is passed through a registered mapper before the value is serialized by the normal serialization mechanism and then sent to the client.
The endpoint TypeScript is generated based on the mapped types.
For example, a method like
public Page<Person> list(Pageable pageable) {
}
generates a TypeScript and converts data as if the method was defined as
public List<Person> list(com.vaadin.fusion.mappedtypes.Pageable pageable) {
}
Modifier and Type | Class and Description |
---|---|
static interface |
EndpointTransferMapper.Mapper<ENDPOINTTYPE,TRANSFERTYPE>
A mapper for endpoint values that is capable of converting between the
given endpoint and transfer type.
|
Constructor and Description |
---|
EndpointTransferMapper()
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
<T> EndpointTransferMapper.Mapper |
getMapper(Class<T> endpointType)
Gets the mapper for the given endpoint type.
|
Class<?> |
getTransferType(Class<?> endpointType)
Gets the transfer type for the given endpoint type.
|
String |
getTransferType(String endpointType)
Gets the transfer type for the given endpoint type.
|
<T> T |
toEndpointType(Object transferValue,
Class<T> endpointType)
Converts the given object from its transfer type to the given endpoint
type.
|
Object |
toTransferType(Object endpointValue)
Converts the given object from its endpoint type to its transfer type.
|
public Class<?> getTransferType(Class<?> endpointType)
NOTE that this is intended for checking the type of a value being sent at runtime and thus checks also the super types / interfaces of the given type.
The returned transfer type is the same as the endpoint type if no conversion is needed.
endpointType
- the endpoint typepublic String getTransferType(String endpointType)
NOTE that this is intended to be used when generating TypeScript and it DOES NOT check super types / interfaces of the given type.
The returned transfer type is the same as the endpoint type if no conversion is needed.
endpointType
- the endpoint typepublic <T> EndpointTransferMapper.Mapper getMapper(Class<T> endpointType)
NOTE that this is intended for runtime and thus checks also the super types / interfaces of the given type.
T
- the endpoint typeendpointType
- the endpoint typepublic Object toTransferType(Object endpointValue)
endpointValue
- the value returned from the endpointpublic <T> T toEndpointType(Object transferValue, Class<T> endpointType)
T
- the endpoint typetransferValue
- the value transferred over the networkendpointType
- the value type declared in the endpoint, as parameter or
return typeCopyright © 2024. All rights reserved.