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 jvm static sender 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 Details

  • Constructor Details

  • Method Details

    • of

      Creates a new channel message sender with the given name and environment. If you want the sender representation of the current network component consider using self() 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

      @NonNull public static @NonNull ChannelMessageSender self()
      Get a jvm static sender representation of this network component.
      Returns:
      a sender representation of this network component.
    • is

      public boolean is(@NonNull @NonNull ServiceInfoSnapshot serviceInfoSnapshot)
      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 snapshot is null.
    • is

      public boolean is(@NonNull @NonNull NetworkClusterNode node)
      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 input is null.
    • toTarget

      Converts this sender to a target. The target has either the type ChannelMessageTarget.Type.NODE if this sender represents a node, or the type ChannelMessageTarget.Type.SERVICE if this sender represents a wrapper (or is running embedded).
      Returns:
      a new ChannelMessageTarget based on the information of this sender.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      @NonNull public @NonNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • type

      Returns the value of the type record component.
      Returns:
      the value of the type record component