com.vaadin.hilla.endpointransfermapper.
Class EndpointTransferMapper
Defines mappings for certain endpoint types to corresponding transfer types. This allows using beans / classes in endpoints which cannot be serialized by the standard bean serialization.
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.hilla.mappedtypes.Pageable pageable) {
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
A mapper for endpoint values that is capable of converting between the given endpoint and transfer type.
static class
A deserializer for MultipartFile.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.fasterxml.jackson.databind.Module
Gets the Jackson 2 module configured with the mapping serializers and deserializers.
Gets the mapper for the given endpoint type.
Class<?>
getTransferType
(Class<?> endpointType) Gets the transfer type for the given endpoint type.
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.
toTransferType
(Object endpointValue) Converts the given object from its endpoint type to its transfer type.
-
Constructor Details
-
EndpointTransferMapper
public EndpointTransferMapper()Creates a new instance.
-
-
Method Details
-
getJacksonModule
public com.fasterxml.jackson.databind.Module getJacksonModule()Gets the Jackson 2 module configured with the mapping serializers and deserializers.
For internal use only. May be changed or removed in a future release.
Returns:
Jackson 2 module.
-
getTransferType
Gets the transfer type for the given endpoint type.
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.
Parameters:
endpointType
- the endpoint typeReturns:
the transfer type or null if no mapping exists
-
getTransferType
Gets the transfer type for the given endpoint type.
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.
Parameters:
endpointType
- the endpoint typeReturns:
the transfer type or null if no mapping exists
-
getMapper
Gets the mapper for the given endpoint type.
NOTE that this is intended for runtime and thus checks also the super types / interfaces of the given type.
Type Parameters:
T
- the endpoint typeParameters:
endpointType
- the endpoint typeReturns:
the transfer type or null if no mapper exists
-
toTransferType
Converts the given object from its endpoint type to its transfer type.
Parameters:
endpointValue
- the value returned from the endpointReturns:
the value converted to its transfer type
-
toEndpointType
Converts the given object from its transfer type to the given endpoint type.
Type Parameters:
T
- the endpoint typeParameters:
transferValue
- the value transferred over the networkendpointType
- the value type declared in the endpoint, as parameter or return typeReturns:
the value converted to its endpoint type
-