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 newGsonNotificationReaderthat 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 theStoredEventthat theNotificationis based on.zonedDateTimeValue(String fieldName) Gives the value of a field in the domain event as ajava.time.ZonedDateTimeobject.
-
Constructor Details
-
GsonNotificationReader
Creates a newGsonNotificationReaderthat parses the given JSON-serialized notification.- Parameters:
jsonNotification- the JSON representation of the notification to read- Throws:
IllegalArgumentException- ifjsonNotificationisnullor not a valid JSON object
-
-
Method Details
-
eventType
Description copied from interface:NotificationReaderGives the name of the domain event class.- Specified by:
eventTypein interfaceNotificationReader- Returns:
- the name of the domain event class
-
storedEventId
Description copied from interface:NotificationReaderGives the ID of theStoredEventthat theNotificationis based on.- Specified by:
storedEventIdin interfaceNotificationReader- Returns:
- the ID of the
StoredEvent
-
occurredOn
Description copied from interface:NotificationReaderGives the date and time when the domain event occurred.- Specified by:
occurredOnin interfaceNotificationReader- Returns:
- the date and time the domain event occurred
-
eventVersion
Description copied from interface:NotificationReaderGives the version of the domain event.- Specified by:
eventVersionin interfaceNotificationReader- Returns:
- the version of the domain event
-
eventIntValue
Description copied from interface:NotificationReaderGives the integer value of a field in the domain event.- Specified by:
eventIntValuein 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:NotificationReaderGives the long integer value of a field in the domain event.- Specified by:
eventLongValuein 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:NotificationReaderGives the double value of a field in the domain event.- Specified by:
eventDoubleValuein 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:NotificationReaderGives the string value of a field in the domain event.- Specified by:
eventStringValuein 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:NotificationReaderGives the value of a field in the domain event as ajava.time.ZonedDateTimeobject.- Specified by:
zonedDateTimeValuein interfaceNotificationReader- Parameters:
fieldName- the name of the field to lookup, potentially nested, e.g., "foo.bar"- Returns:
- the optional
java.time.ZonedDateTimevalue of the field
-