public class ChannelMessage<M,D>
extends java.lang.Object
Constructor and Description |
---|
ChannelMessage(D data)
Creates a new instance with no metadata.
|
ChannelMessage(M metadata,
D data)
Creates a new instance.
|
ChannelMessage(java.util.Optional<M> metadata,
D data)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
D |
data() |
boolean |
equals(java.lang.Object x) |
int |
hashCode() |
static <M,D> ChannelMessage<M,D> |
message(D data)
Syntactic sugar for the
one-argument
constructor . |
static <M,D> ChannelMessage<M,D> |
message(M metadata,
D data)
Syntactic sugar for the
two-argument constructor . |
static <M,D> ChannelMessage<M,D> |
message(java.util.Optional<M> metadata,
D data)
Syntactic sugar for the
two-argument constructor . |
java.util.Optional<M> |
metadata() |
public ChannelMessage(java.util.Optional<M> metadata, D data)
metadata
- any metadata accompanying the data to consume.data
- the data to consume.java.lang.NullPointerException
- if any argument is null
.public ChannelMessage(M metadata, D data)
metadata
- any metadata accompanying the data to consume.data
- the data to consume.java.lang.NullPointerException
- if any argument is null
.public ChannelMessage(D data)
data
- the data to consume.java.lang.NullPointerException
- if the argument is null
.public static <M,D> ChannelMessage<M,D> message(java.util.Optional<M> metadata, D data)
two-argument constructor
.M
- the metadata type.D
- the data type.metadata
- the optional metadata.data
- the data.public static <M,D> ChannelMessage<M,D> message(M metadata, D data)
two-argument constructor
.M
- the metadata type.D
- the data type.metadata
- the metadata.data
- the data.public static <M,D> ChannelMessage<M,D> message(D data)
one-argument
constructor
.M
- the metadata type.D
- the data type.data
- the data.public java.util.Optional<M> metadata()
data
to consume or
empty if the sender specified no metadata.public D data()
public boolean equals(java.lang.Object x)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object