Class GsonNotificationReader
java.lang.Object
com.reallifedeveloper.common.infrastructure.GsonNotificationReader
- All Implemented Interfaces:
NotificationReader
An implementation of the
NotificationReader
interface that works with JSON as the serialized form, using
Gson to parse the JSON string.- Author:
- RealLifeDeveloper
-
Constructor Summary
ConstructorsConstructorDescriptionGsonNotificationReader
(String jsonNotification) Creates a newGsonNotificationReader
that parses the given JSON-serialized notification. -
Method Summary
Modifier and TypeMethodDescriptioneventDoubleValue
(String fieldName) Gives the double value of a field in the domain event.eventIntValue
(String fieldName) Gives the integer value of a field in the domain event.eventLongValue
(String fieldName) Gives the long integer value of a field in the domain event.eventStringValue
(String fieldName) Gives the string value of a field in the domain event.Gives the name of the domain event class.Gives the version of the domain event.Gives the date and time when the domain event occurred.Gives the ID of theStoredEvent
that theNotification
is based on.zonedDateTimeValue
(String fieldName) Gives the value of a field in the domain event as ajava.time.ZonedDateTime
object.
-
Constructor Details
-
GsonNotificationReader
Creates a newGsonNotificationReader
that parses the given JSON-serialized notification.- Parameters:
jsonNotification
- the JSON representation of the notification to read- Throws:
IllegalArgumentException
- ifjsonNotification
isnull
or not a valid JSON object
-
-
Method Details
-
eventType
Description copied from interface:NotificationReader
Gives the name of the domain event class.- Specified by:
eventType
in interfaceNotificationReader
- Returns:
- the name of the domain event class
-
storedEventId
Description copied from interface:NotificationReader
Gives the ID of theStoredEvent
that theNotification
is based on.- Specified by:
storedEventId
in interfaceNotificationReader
- Returns:
- the ID of the
StoredEvent
-
occurredOn
Description copied from interface:NotificationReader
Gives the date and time when the domain event occurred.- Specified by:
occurredOn
in interfaceNotificationReader
- Returns:
- the date and time the domain event occurred
-
eventVersion
Description copied from interface:NotificationReader
Gives the version of the domain event.- Specified by:
eventVersion
in interfaceNotificationReader
- Returns:
- the version of the domain event
-
eventIntValue
Description copied from interface:NotificationReader
Gives the integer value of a field in the domain event.- Specified by:
eventIntValue
in interfaceNotificationReader
- Parameters:
fieldName
- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optoinl integer value of the field
-
eventLongValue
Description copied from interface:NotificationReader
Gives the long integer value of a field in the domain event.- Specified by:
eventLongValue
in interfaceNotificationReader
- Parameters:
fieldName
- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optional long integer value of the field
-
eventDoubleValue
Description copied from interface:NotificationReader
Gives the double value of a field in the domain event.- Specified by:
eventDoubleValue
in interfaceNotificationReader
- Parameters:
fieldName
- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optional double value of the field
-
eventStringValue
Description copied from interface:NotificationReader
Gives the string value of a field in the domain event.- Specified by:
eventStringValue
in interfaceNotificationReader
- Parameters:
fieldName
- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optional string value of the field
-
zonedDateTimeValue
Description copied from interface:NotificationReader
Gives the value of a field in the domain event as ajava.time.ZonedDateTime
object.- Specified by:
zonedDateTimeValue
in interfaceNotificationReader
- Parameters:
fieldName
- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optional
java.time.ZonedDateTime
value of the field
-