Class ChannelMessageTarget

java.lang.Object
eu.cloudnetservice.driver.channel.ChannelMessageTarget

public final class ChannelMessageTarget extends Object
Identifies one or more targets of a channel message, optionally with a name() for further specification of a target. A channel message target can, for example, represent all components in the network or only a single node or service. For services, there are special targets for filtering, for example, based on the task they are based on.
Since:
4.0
  • Field Details

  • Constructor Details

    • ChannelMessageTarget

      private ChannelMessageTarget(@NonNull @NonNull ChannelMessageTarget.Type type, @Nullable @Nullable String name)
      Constructs a new channel message target using the given type and optional name. For internal use only.
      Parameters:
      type - the type of component targeted by this channel message target.
      name - an optional name to further narrow the target. The meaning of the name is derived from the type.
      Throws:
      NullPointerException - if the given type is null.
  • Method Details

    • all

      @NonNull public static @NonNull ChannelMessageTarget all()
      Get a channel message target that targets all components in the network.
      Returns:
      a channel message target that targets all components in the network.
    • allNodes

      @NonNull public static @NonNull ChannelMessageTarget allNodes()
      Get a channel message target that targets all node components in the network.
      Returns:
      a channel message target that targets all node components in the network.
    • allServices

      @NonNull public static @NonNull ChannelMessageTarget allServices()
      Get a channel message target that targets all service (wrapper) components in the network.
      Returns:
      a channel message target that targets all service components in the network.
    • node

      Get a channel message target that targets the given node in the network.
      Parameters:
      node - the node to target.
      Returns:
      a channel message target that targets the given node in the network.
      Throws:
      NullPointerException - if the given node to target is null.
    • node

      Get a channel message target that targets the node with the given name in the network.
      Parameters:
      nodeId - the id of the node to target.
      Returns:
      a channel message target that targets the node with the given name in the network.
      Throws:
      NullPointerException - if the given node id is null.
    • service

      @NonNull public static @NonNull ChannelMessageTarget service(@NonNull @NonNull ServiceId serviceId)
      Get a channel message target that targets the given service. Note that services are identified by their name and not by their unique id, therefore a channel message might be sent to a different service if the actual target restarts.
      Parameters:
      serviceId - the service id of the service to target.
      Returns:
      a channel message target that targets the given service.
      Throws:
      NullPointerException - if the given service id is null.
    • service

      @NonNull public static @NonNull ChannelMessageTarget service(@NonNull @NonNull String serviceName)
      Get a channel message target that targets the service identified by the given name. Note that services are identified by their name and not by their unique id, therefore a channel message might be sent to a different service if the actual target restarts.
      Parameters:
      serviceName - the name of the service to target.
      Returns:
      a channel message target that targets the service identified by the given name.
      Throws:
      NullPointerException - if the given service name is null.
    • servicesByTask

      @NonNull public static @NonNull ChannelMessageTarget servicesByTask(@NonNull @NonNull ServiceTask task)
      Get a channel message target that targets all services that are based on the given service task.
      Parameters:
      task - the service task to target.
      Returns:
      a channel message target that targets all services that are based on the given service task.
      Throws:
      NullPointerException - if the given service task is null.
    • servicesByTask

      @NonNull public static @NonNull ChannelMessageTarget servicesByTask(@NonNull @NonNull String taskName)
      Get a channel message target that targets all services that are based on the service task identified by the given name.
      Parameters:
      taskName - the name of the task to target.
      Returns:
      a channel message target that targets all services that are based on the given service task.
      Throws:
      NullPointerException - if the given service task name is null.
    • servicesByGroup

      Get a channel message target that targets all services that are in the given group.
      Parameters:
      group - the group to target.
      Returns:
      a channel message target that targets all services that are in the given group.
      Throws:
      NullPointerException - if the given group is null.
    • servicesByGroup

      @NonNull public static @NonNull ChannelMessageTarget servicesByGroup(@NonNull @NonNull String groupName)
      Get a channel message target that targets all services that are in the group identified by the given name.
      Parameters:
      groupName - the name of the group to target.
      Returns:
      a channel message target that targets all services that are in the given group.
      Throws:
      NullPointerException - if the given group name is null.
    • servicesByEnvironment

      @NonNull public static @NonNull ChannelMessageTarget servicesByEnvironment(@NonNull @NonNull ServiceEnvironmentType environment)
      Get a channel message target that targets all services that are using the given service environment.
      Parameters:
      environment - the environment to target.
      Returns:
      a channel message target that targets all services that are using the given service environment.
      Throws:
      NullPointerException - if the given environment is null.
    • servicesByEnvironment

      @NonNull public static @NonNull ChannelMessageTarget servicesByEnvironment(@NonNull @NonNull String environmentName)
      Get a channel message target that targets all services that are using the service environment identified by the given name.
      Parameters:
      environmentName - the name of the environment to target.
      Returns:
      a channel message target that targets all services that are using the given service environment.
      Throws:
      NullPointerException - if the given environment name is null.
    • servicesWithProperty

      @NonNull public static @NonNull ChannelMessageTarget servicesWithProperty(@NonNull @NonNull DocProperty<?> property)
      Get a channel message target that targets all services that have the given property associated with any value.
      Parameters:
      property - the property that must be associated on target services.
      Returns:
      a channel message target that targets all services that have the given property associated with any value.
      Throws:
      NullPointerException - if the given property is null.
    • servicesWithProperty

      @NonNull public static @NonNull ChannelMessageTarget servicesWithProperty(@NonNull @NonNull String propertyKey)
      Get a channel message target that targets all services that have the property identified by the given key associated with any value.
      Parameters:
      propertyKey - the key of the property that must be associated on target services.
      Returns:
      a channel message target that targets all services that have the given property associated with any value.
      Throws:
      NullPointerException - if the given property key is null.
    • type

      Get the type of component that is targeted. For internal differentiation only.
      Returns:
      the type of component that is targeted.
    • name

      @Internal public @UnknownNullability("only null when the associated target type does not demand a name") String name()
      Get an optional name of the target component. Can be null if the target type does not demand for a name (for example, when targeting all services). For internal differentiation only.
      Returns:
      an optional name of the target component.
    • equals

      public boolean equals(@Nullable @Nullable Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @NonNull public @NonNull String toString()
      Overrides:
      toString in class Object