public class PubSubMessage extends Object implements Serializable, JSONFormatter
Modifier and Type | Field and Description |
---|---|
static Charset |
CHARSET |
GSON, INVALID_DOUBLES
Constructor and Description |
---|
PubSubMessage()
Constructor for a message having no information.
|
PubSubMessage(String id,
byte[] content)
Constructor for a message having only content.
|
PubSubMessage(String id,
byte[] content,
Metadata.Signal signal)
Constructor for a message having content and a
Metadata.Signal . |
PubSubMessage(String id,
byte[] content,
Metadata metadata)
Constructor for a message having content and
Metadata . |
PubSubMessage(String id,
Metadata.Signal signal)
Constructor for a message having only a
Metadata.Signal . |
PubSubMessage(String id,
String content)
Constructor for a message having only content as a String.
|
PubSubMessage(String id,
String content,
Metadata metadata)
Constructor for a message having content as a String and
Metadata . |
Modifier and Type | Method and Description |
---|---|
String |
asJSON()
Convert this object to a JSON string.
|
boolean |
equals(Object other) |
static PubSubMessage |
fromJSON(String json)
Converts a json representation back to an instance.
|
String |
getContentAsString()
Returns the content stored in the message as a String.
|
boolean |
hasContent()
Check if message has content.
|
int |
hashCode() |
boolean |
hasMetadata()
Check if message has
Metadata . |
boolean |
hasSignal()
Check if the message has a
Metadata.Signal . |
boolean |
hasSignal(Metadata.Signal signal)
Check if message has a given
Metadata.Signal . |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
asJSON, fromJSON
public static final Charset CHARSET
public PubSubMessage()
public PubSubMessage(String id, Metadata.Signal signal)
Metadata.Signal
.id
- The ID associated with the message.signal
- The signal only for the Metadata.public PubSubMessage(String id, byte[] content)
id
- The ID associated with the message.content
- The content of the message.public PubSubMessage(String id, String content)
id
- The ID associated with the message.content
- The content of the message as a String.public PubSubMessage(String id, byte[] content, Metadata.Signal signal)
Metadata.Signal
.id
- The ID associated with the message.content
- The content of the message.signal
- The Signal to be sent with the message.public PubSubMessage(String id, String content, Metadata metadata)
Metadata
.id
- The ID associated with the message.content
- The content of the message as a String.metadata
- The Metadata associated with the message.public boolean hasContent()
public boolean hasMetadata()
Metadata
.public boolean hasSignal(Metadata.Signal signal)
Metadata.Signal
.signal
- The signal to check for.public boolean hasSignal()
Metadata.Signal
.public String getContentAsString()
CHARSET
.public String asJSON()
JSONFormatter
asJSON
in interface JSONFormatter
public static PubSubMessage fromJSON(String json)
json
- The string representation of the JSON.Copyright © 2021. All rights reserved.