Class EventFactory


  • public class EventFactory
    extends Object
    A Factory class to create the event classes from the JSON (JsonNode). The handling of parsing the events can be modificated through the "parseMapping" variable.
    • Constructor Detail

      • EventFactory

        public EventFactory​(Map<String,​City> cities)
        Constructor for EventFactory with given city map.
        Parameters:
        cities - City map, where the key is the String name of the city
    • Method Detail

      • parseFromJsonNode

        public BaseEvent parseFromJsonNode​(com.fasterxml.jackson.databind.JsonNode node)
        Parse the event from a JsonNode object.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        Returns:
        The parsed event as object or null, if an error occurred
      • parseOtherEvent

        public BaseEvent parseOtherEvent​(com.fasterxml.jackson.databind.JsonNode node)
        Parse an OtherEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        Returns:
        a BaseEvent object with the parsed attributes or null on error.
      • parseSimpleEvent

        public BaseEvent parseSimpleEvent​(com.fasterxml.jackson.databind.JsonNode node,
                                          String roundAttribute,
                                          Supplier<SimpleEvent> constructor)
        Parse an SimpleEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        roundAttribute - The name of the round attribute (e.g. sinceRound)
        constructor - The class instructor for the SimpleEvent object.
        Returns:
        a SimpleEvent object with the parsed attributes or null on error.
      • parsePathogenEvent

        public BaseEvent parsePathogenEvent​(com.fasterxml.jackson.databind.JsonNode node,
                                            String roundAttribute,
                                            Supplier<PathogenEvent> constructor)
        Parse a PathogenEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        roundAttribute - The name of the round attribute (e.g. sinceRound)
        constructor - The class instructor for the PathogenEvent object.
        Returns:
        a SimpleEvent object with the parsed attributes or null on error.
      • parseTimedEvent

        public BaseEvent parseTimedEvent​(com.fasterxml.jackson.databind.JsonNode node,
                                         Supplier<TimedEvent> constructor)
        Parse a TimedEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        constructor - The class instructor for the TimedEvent object.
        Returns:
        a TimedEvent object with the parsed attributes or null on error.
      • parseInDevelopmentEvent

        public BaseEvent parseInDevelopmentEvent​(com.fasterxml.jackson.databind.JsonNode node,
                                                 Supplier<InDevelopmentEvent> constructor)
        Parse a InDevelopmentEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        constructor - The class instructor for the PathogenEvent object.
        Returns:
        a InDevelopmentEvent object with the parsed attributes or null on error.
      • parseConnectionClosedEvent

        public BaseEvent parseConnectionClosedEvent​(com.fasterxml.jackson.databind.JsonNode node)
        Parse a ConnectionClosedEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        Returns:
        a ConnectionClosedEvent object with the parsed attributes or null on error.
      • parseUprisingEvent

        public UprisingEvent parseUprisingEvent​(com.fasterxml.jackson.databind.JsonNode node)
        Parse a UprisingEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        Returns:
        a UprisingEvent object with the parsed attributes or null on error.
      • parseOutbreakEvent

        public OutbreakEvent parseOutbreakEvent​(com.fasterxml.jackson.databind.JsonNode node)
        Parse a OutbreakEvent object from a given JsonNode.
        Parameters:
        node - A JsonNode object, where the values should be parseable.
        Returns:
        a OutbreakEvent object with the parsed attributes or null on error.