Module com.legyver.utils.mapqua
Class MapBackedEntity<T extends MapSyncable>
- java.lang.Object
-
- com.legyver.utils.mapqua.mapbacked.MapBackedProperty<T>
-
- com.legyver.utils.mapqua.mapbacked.MapBackedEntity<T>
-
public class MapBackedEntity<T extends MapSyncable> extends MapBackedProperty<T>
An Entity variable that can be represented as a key-value pair in the POJO internal Map
-
-
Field Summary
-
Fields inherited from class com.legyver.utils.mapqua.mapbacked.MapBackedProperty
property, sourceMap, valueIfMissing
-
-
Constructor Summary
Constructors Constructor Description MapBackedEntity(java.util.Map sourceMap, java.lang.String property, EntityInstantiator<T> entityInstantiator)Construct a MapBackedEntity with a certain property name and default value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget()Retrieve the wrapped entityprotected java.util.Optional<T>queryOption()Hook to allow the property to be queryable-
Methods inherited from class com.legyver.utils.mapqua.mapbacked.MapBackedProperty
set
-
-
-
-
Constructor Detail
-
MapBackedEntity
public MapBackedEntity(java.util.Map sourceMap, java.lang.String property, EntityInstantiator<T> entityInstantiator)Construct a MapBackedEntity with a certain property name and default value- Parameters:
sourceMap- Map to store the Entity value inproperty- Key name of the propertyentityInstantiator- function to use when adding a value to the Entity
-
-
Method Detail
-
get
public T get() throws com.legyver.core.exception.CoreException
Retrieve the wrapped entity- Overrides:
getin classMapBackedProperty<T extends MapSyncable>- Returns:
- the existing entity or an new Entity instantiated from the EntityInstantiator
- Throws:
com.legyver.core.exception.CoreException- if there is a problem marshalling to/from JSON
-
queryOption
protected java.util.Optional<T> queryOption()
Description copied from class:MapBackedPropertyHook to allow the property to be queryable- Specified by:
queryOptionin classMapBackedProperty<T extends MapSyncable>- Returns:
- the query option to use for the Property
-
-