Package es.kukenan.smartfi.events.common
Class AbstractEventParser<T extends Event>
java.lang.Object
es.kukenan.smartfi.events.common.AbstractEventParser<T>
- Type Parameters:
T- the event class this parser handles.
- All Implemented Interfaces:
EventParser
- Direct Known Subclasses:
ScheduledEventParser
Base class for any event parser.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe context which events this parser is able to handle (that must be mapped to the given class).private final CustomObjectMapperJackson event mapper.TThe event class this parser handles. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractEventParser(CustomObjectMapper customObjectMapper, Class<T> eventClass, String context) Class constructor. -
Method Summary
-
Field Details
-
customObjectMapper
Jackson event mapper. -
eventClass
TThe event class this parser handles. -
context
The context which events this parser is able to handle (that must be mapped to the given class).
-
-
Constructor Details
-
AbstractEventParser
public AbstractEventParser(@NonNull CustomObjectMapper customObjectMapper, @NonNull Class<T> eventClass, @NonNull String context) Class constructor.- Parameters:
customObjectMapper- object mapper that will be used to serialize/deserialize json.eventClass- the event class this parser is going to handle.context- the context which events this parser is able to handle (that must be mapped to the given class).
-
-
Method Details
-
wants
public boolean wants(com.fasterxml.jackson.databind.JsonNode jsonNode) Description copied from interface:EventParserReturns true if the parser is able to deserialize the given json.- Specified by:
wantsin interfaceEventParser<T extends Event>- Parameters:
jsonNode- a json.- Returns:
- true if the given json can be deserialized using this parser.
-
parse
Description copied from interface:EventParserDesierialize the given json.- Specified by:
parsein interfaceEventParser<T extends Event>- Parameters:
jsonNode- the json to deserialize.- Returns:
- the event described in the given json.
-