Class LeafletObject
java.lang.Object
org.vaadin.addons.componentfactory.leaflet.LeafletObject
- All Implemented Interfaces:
Serializable,Identifiable,ExecutableFunctions
- Direct Known Subclasses:
Layer,LeafletControl
Base class for serializable client-side Leaflet objects. It provides a unique
identifier, JSON serialization and access to the Leaflet constructor
arguments declared through
LeafletArgument.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new Leaflet object, initializing its Jackson mapper and assigning it a random unique identifier. -
Method Summary
Modifier and TypeMethodDescription<T extends Serializable>
CompletableFuture<T> call(Identifiable target, String functionName, Class<T> resultType, Serializable... arguments) Delegates a client-side function call, returning a result, to the parent, if any.protected voidconfigureObjectMapper(tools.jackson.databind.json.JsonMapper.Builder builder) Hook for subclasses to customize the Jackson mapper used for serializing this object.voidexecuteJs(Identifiable target, String functionName, Serializable... arguments) Delegates the execution of the named client-side function to the parent, if any.Returns the names of the fields used as client-side constructor arguments, ordered by theirLeafletArgumentindex.getJson()Returns the JSON representation of this object, computing it lazily on first access.Returns the Leaflet type name of this object, used to instantiate the matching class on the client side.protected ExecutableFunctionsReturns the parent through which client-side function calls are delegated.getUuid()Returns the unique identifier of this object.protected voidsetParent(ExecutableFunctions parent) Sets the parent through which client-side function calls are delegated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.vaadin.addons.componentfactory.leaflet.layer.map.functions.ExecutableFunctions
call, executeJs
-
Constructor Details
-
LeafletObject
protected LeafletObject()Creates a new Leaflet object, initializing its Jackson mapper and assigning it a random unique identifier.
-
-
Method Details
-
configureObjectMapper
protected void configureObjectMapper(tools.jackson.databind.json.JsonMapper.Builder builder) Hook for subclasses to customize the Jackson mapper used for serializing this object. Jackson 3 mappers are immutable, so configuration must be applied to theJsonMapper.Builderbefore the mapper is built.- Parameters:
builder- the mapper builder to configure
-
getUuid
Returns the unique identifier of this object.- Specified by:
getUuidin interfaceIdentifiable- Returns:
- the object uuid
-
getJson
Returns the JSON representation of this object, computing it lazily on first access.- Returns:
- the JSON representation of this object
-
getConstructorArgumentNames
Returns the names of the fields used as client-side constructor arguments, ordered by theirLeafletArgumentindex.- Returns:
- the constructor argument names
-
getLeafletType
Returns the Leaflet type name of this object, used to instantiate the matching class on the client side.- Returns:
- the Leaflet type name
-
executeJs
Delegates the execution of the named client-side function to the parent, if any.- Specified by:
executeJsin interfaceExecutableFunctions- Parameters:
target- the client object to invoke the function onfunctionName- the name of the function to callarguments- the arguments passed to the function
-
call
public <T extends Serializable> CompletableFuture<T> call(Identifiable target, String functionName, Class<T> resultType, Serializable... arguments) Delegates a client-side function call, returning a result, to the parent, if any.- Specified by:
callin interfaceExecutableFunctions- Type Parameters:
T- the type of the returned result- Parameters:
target- the client object to invoke the function onfunctionName- the name of the function to callresultType- the type the client result should be deserialized toarguments- the arguments passed to the function- Returns:
- a future completed with the function result, or
nullif there is no parent to delegate to
-
setParent
Sets the parent through which client-side function calls are delegated.- Parameters:
parent- the parent to set
-
getParent
Returns the parent through which client-side function calls are delegated.- Returns:
- the parent
-