Package me.tamkungz.signals
Class SignalKey<T>
java.lang.Object
me.tamkungz.signals.SignalKey<T>
- Type Parameters:
T- payload type
Identifies one signal channel: a payload type plus a name.
Keys with the same type and name address the same channel; derived keys created by
Signal.filter(java.util.function.Predicate<T>) and Signal.map(java.lang.Class<R>, java.util.function.Function<T, R>) are always unique.
Primitive payload types are boxed, so int.class and Integer.class address the same channel
and eventType() reports Integer.class for both.
-
Method Summary
Modifier and TypeMethodDescriptionCasts a value to this key's payload type.booleanReturns the payload type, with primitives boxed.inthashCode()name()Returns the channel name.static <T> SignalKey<T> Returns the key of a named channel for a payload type.static <T> SignalKey<T> Returns the default key of a payload type, the same asnamed(eventType, "default").toString()
-
Method Details
-
of
Returns the default key of a payload type, the same asnamed(eventType, "default").- Type Parameters:
T- payload type- Parameters:
eventType- payload type- Returns:
- the default key for the type
-
named
Returns the key of a named channel for a payload type.- Type Parameters:
T- payload type- Parameters:
eventType- payload typename- channel name- Returns:
- the key for that type and name
-
eventType
Returns the payload type, with primitives boxed.- Returns:
- payload class
-
name
Returns the channel name.- Returns:
- channel name
-
cast
Casts a value to this key's payload type.- Parameters:
value- value to cast, may benull- Returns:
- the value as
T - Throws:
ClassCastException- if the value is not an instance of the payload type
-
equals
-
hashCode
public int hashCode() -
toString
-