Class ChannelMessageTarget
java.lang.Object
eu.cloudnetservice.driver.channel.ChannelMessageTarget
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe possible types of targets a channel message can have. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ChannelMessageTargetprivate static final ChannelMessageTargetprivate static final ChannelMessageTargetprivate final Stringprivate final ChannelMessageTarget.Type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateConstructs a new channel message target using the given type and optional name. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull ChannelMessageTargetall()Get a channel message target that targets all components in the network.static @NonNull ChannelMessageTargetallNodes()Get a channel message target that targets all node components in the network.static @NonNull ChannelMessageTargetGet a channel message target that targets all service (wrapper) components in the network.booleaninthashCode()@UnknownNullability("only null when the associated target type does not demand a name") Stringname()Get an optional name of the target component.static @NonNull ChannelMessageTargetnode(@NonNull NetworkClusterNode node) Get a channel message target that targets the given node in the network.static @NonNull ChannelMessageTargetGet a channel message target that targets the node with the given name in the network.static @NonNull ChannelMessageTargetGet a channel message target that targets the given service.static @NonNull ChannelMessageTargetGet a channel message target that targets the service identified by the given name.static @NonNull ChannelMessageTargetservicesByEnvironment(@NonNull ServiceEnvironmentType environment) Get a channel message target that targets all services that are using the given service environment.static @NonNull ChannelMessageTargetservicesByEnvironment(@NonNull String environmentName) Get a channel message target that targets all services that are using the service environment identified by the given name.static @NonNull ChannelMessageTargetGet a channel message target that targets all services that are in the given group.static @NonNull ChannelMessageTargetservicesByGroup(@NonNull String groupName) Get a channel message target that targets all services that are in the group identified by the given name.static @NonNull ChannelMessageTargetGet a channel message target that targets all services that are based on the given service task.static @NonNull ChannelMessageTargetservicesByTask(@NonNull String taskName) Get a channel message target that targets all services that are based on the service task identified by the given name.static @NonNull ChannelMessageTargetservicesWithProperty(@NonNull DocProperty<?> property) Get a channel message target that targets all services that have the given property associated with any value.static @NonNull ChannelMessageTargetservicesWithProperty(@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.toString()type()Get the type of component that is targeted.
-
Field Details
-
ALL
-
ALL_NODES
-
ALL_SERVICES
-
type
-
name
-
-
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
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
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
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
@NonNull public static @NonNull ChannelMessageTarget node(@NonNull @NonNull NetworkClusterNode 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
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
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
@NonNull public static @NonNull ChannelMessageTarget servicesByGroup(@NonNull @NonNull GroupConfiguration group) 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
-
hashCode
-
toString
-