Record Class ChannelMessageSender
java.lang.Object
java.lang.Record
eu.cloudnetservice.driver.channel.ChannelMessageSender
- Record Components:
name- the name of the new sender.type- the type of the new sender.
public record ChannelMessageSender(@NonNull String name, @NonNull DriverEnvironment type)
extends Record
Represents a sender of a channel message. A channel message sender is not required to be the actual component sending
the message, nor is there a requirement for the name to match the driver environment when creating a new target. But
it is strongly recommended to not mismatch information as it may lead to confusing results on the receiver site.
Note: It is not recommended using the constructor directly. Consider using either self() if you want a
sender instance representing the current network component or of(String, DriverEnvironment) if you want to
create a sender for another network component.
- Since:
- 4.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionChannelMessageSender(@NonNull String name, @NonNull DriverEnvironment type) Creates an instance of aChannelMessageSenderrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanis(@NonNull NetworkClusterNode node) Checks if this sender represents the given node.booleanis(@NonNull ServiceInfoSnapshot serviceInfoSnapshot) Checks if this sender represents the given service.name()Returns the value of thenamerecord component.static @NonNull ChannelMessageSenderof(@NonNull String name, @NonNull DriverEnvironment environment) Creates a new channel message sender with the given name and environment.static @NonNull ChannelMessageSenderself()Get a jvm static sender representation of this network component.final StringtoString()Returns a string representation of this record class.toTarget()Converts this sender to a target.type()Returns the value of thetyperecord component.
-
Field Details
-
name
-
type
The field for thetyperecord component.
-
-
Constructor Details
-
ChannelMessageSender
-
-
Method Details
-
of
@NonNull public static @NonNull ChannelMessageSender of(@NonNull @NonNull String name, @NonNull @NonNull DriverEnvironment environment) Creates a new channel message sender with the given name and environment. If you want the sender representation of the current network component consider usingself()instead.- Parameters:
name- the name of the new sender.environment- the type of the new sender.- Returns:
- a new channel message sender with the given name and environment.
- Throws:
NullPointerException- if the given name or environment is null.
-
self
Get a jvm static sender representation of this network component.- Returns:
- a sender representation of this network component.
-
is
Checks if this sender represents the given service.- Parameters:
serviceInfoSnapshot- the service to check.- Returns:
- true if this sender represents the given service, false otherwise.
- Throws:
NullPointerException- if the given service snapshot to compare to is null.
-
is
Checks if this sender represents the given node.- Parameters:
node- the node to check.- Returns:
- true if this sender represents the given node, false otherwise.
- Throws:
NullPointerException- if the given node to compare to is null.
-
toTarget
Converts this sender to a target. The target has either the typeChannelMessageTarget.Type.NODEif this sender represents a node, or the typeChannelMessageTarget.Type.SERVICEif this sender represents a wrapper (or is running embedded).- Returns:
- a new
ChannelMessageTargetbased on the information of this sender.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
name
-
type
-