Package de.tubs.pandemieinc
Class EventFactory
- java.lang.Object
-
- de.tubs.pandemieinc.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 Summary
Constructors Constructor Description EventFactory(Map<String,City> cities)
Constructor for EventFactory with given city map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BaseEvent
parseConnectionClosedEvent(com.fasterxml.jackson.databind.JsonNode node)
Parse a ConnectionClosedEvent object from a given JsonNode.BaseEvent
parseFromJsonNode(com.fasterxml.jackson.databind.JsonNode node)
Parse the event from a JsonNode object.BaseEvent
parseInDevelopmentEvent(com.fasterxml.jackson.databind.JsonNode node, Supplier<InDevelopmentEvent> constructor)
Parse a InDevelopmentEvent object from a given JsonNode.BaseEvent
parseOtherEvent(com.fasterxml.jackson.databind.JsonNode node)
Parse an OtherEvent object from a given JsonNode.OutbreakEvent
parseOutbreakEvent(com.fasterxml.jackson.databind.JsonNode node)
Parse a OutbreakEvent object from a given JsonNode.BaseEvent
parsePathogenEvent(com.fasterxml.jackson.databind.JsonNode node, String roundAttribute, Supplier<PathogenEvent> constructor)
Parse a PathogenEvent object from a given JsonNode.BaseEvent
parseSimpleEvent(com.fasterxml.jackson.databind.JsonNode node, String roundAttribute, Supplier<SimpleEvent> constructor)
Parse an SimpleEvent object from a given JsonNode.BaseEvent
parseTimedEvent(com.fasterxml.jackson.databind.JsonNode node, Supplier<TimedEvent> constructor)
Parse a TimedEvent object from a given JsonNode.UprisingEvent
parseUprisingEvent(com.fasterxml.jackson.databind.JsonNode node)
Parse a UprisingEvent object from a given JsonNode.
-
-
-
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.
-
-