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

public abstract class AbstractEventParser<T extends Event> extends Object implements EventParser
Base class for any event parser.
  • Field Details

    • customObjectMapper

      private final CustomObjectMapper customObjectMapper
      Jackson event mapper.
    • eventClass

      private final Class<T extends Event> eventClass
      TThe event class this parser handles.
    • context

      private final String 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: EventParser
      Returns true if the parser is able to deserialize the given json.
      Specified by:
      wants in interface EventParser<T extends Event>
      Parameters:
      jsonNode - a json.
      Returns:
      true if the given json can be deserialized using this parser.
    • parse

      public T parse(com.fasterxml.jackson.databind.JsonNode jsonNode)
      Description copied from interface: EventParser
      Desierialize the given json.
      Specified by:
      parse in interface EventParser<T extends Event>
      Parameters:
      jsonNode - the json to deserialize.
      Returns:
      the event described in the given json.