Package com.yetanalytics.xapi.model
Class Extensions
- java.lang.Object
-
- com.yetanalytics.xapi.model.Extensions
-
public class Extensions extends Object implements IFreeMap<URI,Object>
A wrapper object for using xAPI Extensions. The extension JSON data is stored in a combination of LinkedHashMap and ArrayList depending on the JSON elements. It can be accessed directly or through a JSONPath API.
-
-
Constructor Summary
Constructors Constructor Description Extensions(Map<URI,Object> input)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
get(String key)
Retrieve extension dataObject
get(URI key)
Retrieve extension dataSet<URI>
getKeys()
Returns a set of all IRI Extension keysMap<URI,Object>
getMap()
Returns the full raw Extension Map as a HashMap<URI, Object>void
put(String key, Object value)
Sets an entry in the Extensions Mapvoid
put(URI key, Object value)
Sets an entry in the Extensions Map<T> T
read(String key, String jsonPathExpression, Class<T> typeKey)
Attempt a JSONPath query of the Extension data.<T> T
read(URI key, String jsonPathExpression, Class<T> typeKey)
Attempt a JSONPath query of the Extension data.void
remove(String key)
Remove an extension by IRI keyvoid
remove(URI key)
Remove an extension by IRI key
-
-
-
Method Detail
-
put
public void put(String key, Object value) throws IllegalArgumentException
Sets an entry in the Extensions Map- Specified by:
put
in interfaceIFreeMap<URI,Object>
- Parameters:
key
- the IRI String key of the extensionvalue
- The Collections API representation of the JSON Data- Throws:
IllegalArgumentException
-
get
public Object get(String key) throws IllegalArgumentException
Retrieve extension data- Specified by:
get
in interfaceIFreeMap<URI,Object>
- Parameters:
key
- The IRI string key of the extension- Returns:
- The Collections API representation of the JSON Data
- Throws:
IllegalArgumentException
-
read
public <T> T read(URI key, String jsonPathExpression, Class<T> typeKey)
Attempt a JSONPath query of the Extension data.- Type Parameters:
T
- The type that the query is expecting to convert the results to- Parameters:
key
- The URI key of the extension in which to perform the queryjsonPathExpression
- A JSONPath query to perform in the Extension datatypeKey
- The typereference for the type that the query is expecting to retrieve- Returns:
- Object of type T that is the result of deserialization from the query
-
read
public <T> T read(String key, String jsonPathExpression, Class<T> typeKey) throws IllegalArgumentException
Attempt a JSONPath query of the Extension data.- Type Parameters:
T
- The type that the query is expecting to convert the results to- Parameters:
key
- The IRI String key of the extension in which to perform the queryjsonPathExpression
- A JSONPath query to perform in the Extension datatypeKey
- The typereference for the type that the query is expecting to retrieve- Returns:
- Object of type T that is the result of deserialization from the query
- Throws:
IllegalArgumentException
-
remove
public void remove(URI key)
Remove an extension by IRI key
-
remove
public void remove(String key) throws IllegalArgumentException
Remove an extension by IRI key- Specified by:
remove
in interfaceIFreeMap<URI,Object>
- Parameters:
key
- the IRI String key of the extension to remove- Throws:
IllegalArgumentException
-
-