Interface Lifecycled<T>
- All Known Implementing Classes:
SimpleLifecycled
public interface Lifecycled<T>
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionevents()
Get the event manager for this lifecycled object.default Lifecycled<T>
Filter the value.default <U> Lifecycled<U>
flatMap
(Function<T, Lifecycled<U>> mapper) default boolean
isValid()
Check for validity, usually without triggering computation.default <U> Lifecycled<U>
Map the value.value()
Get the value orOptional.empty()
.default T
Get the value or throw.
-
Method Details
-
value
Get the value orOptional.empty()
.- Returns:
- the value
-
valueOrThrow
Get the value or throw.- Returns:
- the value
- Throws:
IllegalStateException
- if there is no value
-
isValid
default boolean isValid()Check for validity, usually without triggering computation.- Returns:
- if this lifecycled's
value()
is valid
-
events
Lifecycled.Events<T> events()Get the event manager for this lifecycled object.- Returns:
- the event manager
-
map
Map the value.- Type Parameters:
U
- the new type- Parameters:
mapper
- the mapper function- Returns:
- the downstream lifecycled
-
filter
Filter the value. In other words, create a new lifecycled object where validity is ANDed with the result of calling the filter function.- Parameters:
filterer
- the filter function- Returns:
- the downstream lifecycled
-
flatMap
-