Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@

/**
* 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
* 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.
* <p>
* Note: It is not recommended using the constructor directly. Consider using either {@link #self()} if you want a jvm
* static sender representing the current network component or {@link #of(String, DriverEnvironment)} if you want to
* Note: It is not recommended using the constructor directly. Consider using either {@link #self()} if you want a
* sender instance representing the current network component or {@link #of(String, DriverEnvironment)} if you want to
* create a sender for another network component.
*
* @param name the name of the new sender.
Expand Down Expand Up @@ -68,7 +68,7 @@ public record ChannelMessageSender(@NonNull String name, @NonNull DriverEnvironm
*
* @param serviceInfoSnapshot the service to check.
* @return true if this sender represents the given service, false otherwise.
* @throws NullPointerException if the given snapshot is null.
* @throws NullPointerException if the given service snapshot to compare to is null.
*/
public boolean is(@NonNull ServiceInfoSnapshot serviceInfoSnapshot) {
return this.type.equals(DriverEnvironment.WRAPPER) && this.name.equals(serviceInfoSnapshot.name());
Expand All @@ -79,7 +79,7 @@ public boolean is(@NonNull ServiceInfoSnapshot serviceInfoSnapshot) {
*
* @param node the node to check.
* @return true if this sender represents the given node, false otherwise.
* @throws NullPointerException if the given input is null.
* @throws NullPointerException if the given node to compare to is null.
*/
public boolean is(@NonNull NetworkClusterNode node) {
return this.type.equals(DriverEnvironment.NODE) && this.name.equals(node.uniqueId());
Expand All @@ -93,9 +93,7 @@ public boolean is(@NonNull NetworkClusterNode node) {
* @return a new {@link ChannelMessageTarget} based on the information of this sender.
*/
public @NonNull ChannelMessageTarget toTarget() {
var type = this.type.equals(DriverEnvironment.NODE)
? ChannelMessageTarget.Type.NODE
: ChannelMessageTarget.Type.SERVICE;
return new ChannelMessageTarget(type, this.name);
var isNode = this.type.equals(DriverEnvironment.NODE);
return isNode ? ChannelMessageTarget.node(this.name) : ChannelMessageTarget.service(this.name);
}
}
Loading
Loading