Class ChannelMessageTarget
- ALL: includes all network components which are within the network
- NODE: includes all nodes which are within the network
- SERVICE: includes all services which are within the network
- TASK: includes all services of the given task
- GROUP: includes all services which are in the given group
- ENVIRONMENT: includes all services which are using the given environment. See
environment(ServiceEnvironmentType)
A channel message target can optionally take a name of the target. If no name is provided its interpreted as
"all components of the given type". It is illegal to create a target with no name given for the types
ChannelMessageTarget.Type.TASK and ChannelMessageTarget.Type.GROUP. However, a creation of these types in combination with null as the
name is a valid operation and will not fail.
Note: Types are not overriding meaning that setting a target for all services and (for example) specifically the service Abc-1 is valid and will cause the service to receive the channel message twice.
Do not extend this class to get access to it's constructors, use of(Type, String) or for targeting a specific
environment environment(ServiceEnvironmentType) instead.
- Since:
- 4.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents a type of network component this channel message targets. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ChannelMessageTargetprivate static final ChannelMessageTargetprivate static final ChannelMessageTargetprivate final ServiceEnvironmentTypeprivate final Stringprivate final ChannelMessageTarget.Type -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructs a new ChannelMessageTarget with no environment as its target.protectedChannelMessageTarget(@NonNull ChannelMessageTarget.Type type, @Nullable String name, @Nullable ServiceEnvironmentType environment) Internal method used for automated instantiation of this class.protectedChannelMessageTarget(@NonNull ServiceEnvironmentType environment) Constructs a new ChannelMessageTarget targeting a specific service environment. -
Method Summary
Modifier and TypeMethodDescriptionReturns the service environment this ChannelMessageTarget targets.static @NonNull ChannelMessageTargetConstructs a new ChannelMessageTarget targeting a specific service environment.name()Returns the name of the network component this ChannelMessageTarget targets.static @NonNull ChannelMessageTargetof(@NonNull ChannelMessageTarget.Type type, @Nullable String name) Constructs a new ChannelMessageTarget of the given type with the optional name set.type()Returns the type of network component this ChannelMessageTarget targets.
-
Field Details
-
ALL
-
ALL_NODES
-
ALL_SERVICES
-
type
-
name
-
environment
-
-
Constructor Details
-
ChannelMessageTarget
protected ChannelMessageTarget(@NonNull @NonNull ChannelMessageTarget.Type type, @Nullable @Nullable String name) Constructs a new ChannelMessageTarget with no environment as its target.- Parameters:
type- the type of the target.name- the optional name of the target.- Throws:
NullPointerException- if the given type is null.
-
ChannelMessageTarget
Constructs a new ChannelMessageTarget targeting a specific service environment. No name will be set.- Parameters:
environment- the environment of the target.- Throws:
NullPointerException- if the given environment is null.
-
ChannelMessageTarget
protected ChannelMessageTarget(@NonNull @NonNull ChannelMessageTarget.Type type, @Nullable @Nullable String name, @Nullable @Nullable ServiceEnvironmentType environment) Internal method used for automated instantiation of this class.- Parameters:
type- the type of the target.name- the optional name of the target.environment- the optional environment of the target.- Throws:
NullPointerException- if the given type is null.
-
-
Method Details
-
environment
@NonNull public static @NonNull ChannelMessageTarget environment(@NonNull @NonNull ServiceEnvironmentType type) Constructs a new ChannelMessageTarget targeting a specific service environment.- Parameters:
type- the environment to target.- Returns:
- the created ChannelMessageTarget.
- Throws:
NullPointerException- if the given type is null.
-
of
@NonNull public static @NonNull ChannelMessageTarget of(@NonNull @NonNull ChannelMessageTarget.Type type, @Nullable @Nullable String name) Constructs a new ChannelMessageTarget of the given type with the optional name set.- Parameters:
type- the type of the new channel message target.name- optional name of the component with the given type to target.- Returns:
- the created ChannelMessageTarget.
- Throws:
NullPointerException- if given type is null.IllegalArgumentException- if type is ENVIRONMENT. For that purpose useenvironment(ServiceEnvironmentType)instead.
-
type
Returns the type of network component this ChannelMessageTarget targets. Can never be null.- Returns:
- the type of network component this ChannelMessageTarget targets.
-
name
Returns the name of the network component this ChannelMessageTarget targets. This may not be null if the target type is TASK or GROUP, but will always be null if the type is ENVIRONMENT. If a name is given when this channel message target has its type set to ALL it will silently be ignored.- Returns:
- the name of the network component this ChannelMessageTarget targets.
-
environment
Returns the service environment this ChannelMessageTarget targets. This may not be null if the target type is ENVIRONMENT. In all other cases the environment can be non-null but will silently get ignored.- Returns:
- the service environment this ChannelMessageTarget targets.
-