InteractionContext
Provides the user and scenario specific environment for an Interaction .
API
class InteractionContext {
InteractionContext ofUserWithSystemDefaults(UserMemento user) (1)
UserLocale getLocale()
InteractionContext withTimeZoneIfAny(Optional<ZoneId> zoneIdIfAny) (2)
UnaryOperator<InteractionContext> switchUser(UserMemento userMemento) (3)
UnaryOperator<InteractionContext> switchClock(VirtualClock clock) (4)
UnaryOperator<InteractionContext> switchLocale(UserLocale locale) (5)
UnaryOperator<InteractionContext> switchTimeZone(ZoneId timeZone) (6)
UnaryOperator<T> combine(UnaryOperator<T>... mappers) (7)
UnaryOperator<T> combine(Stream<UnaryOperator<T>> mappers) (8)
ZoneOffset getTimeZoneOffsetNow() (9)
}
1 | ofUserWithSystemDefaults(UserMemento)
Creates a new InteractionContext with the specified user and system defaults for clock, locale and time-zone. |
2 | withTimeZoneIfAny(Optional)
Only override if zoneIdIfAny is present, otherwise acts as identity operation. |
3 | switchUser(UserMemento)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified UserMemento . |
4 | switchClock(VirtualClock)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified VirtualClock . |
5 | switchLocale(UserLocale)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified Locale . |
6 | switchTimeZone(ZoneId)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified ZoneId . |
7 | combine(UnaryOperator)
Convenience method to combine UnaryOperator s, for example as per #switchUser(UserMemento) and #switchTimeZone(ZoneId) . |
8 | combine(Stream)
Convenience method to combine UnaryOperator s, for example as per #switchUser(UserMemento) and #switchTimeZone(ZoneId) . credit: https://stackoverflow.com/a/51065029/56880 |
9 | getTimeZoneOffsetNow()
Returns the ZoneOffset at the current time Instant (at which ZoneId rules apply to calculate the offset). |
Members
ofUserWithSystemDefaults(UserMemento)
Creates a new InteractionContext with the specified user and system defaults for clock, locale and time-zone.
withTimeZoneIfAny(Optional)
Only override if zoneIdIfAny is present, otherwise acts as identity operation.
switchUser(UserMemento)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified UserMemento .
switchClock(VirtualClock)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified VirtualClock .
switchLocale(UserLocale)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified Locale .
switchTimeZone(ZoneId)
Convenience method for use with org.apache.causeway.applib.services.sudo.SudoService , returning a UnaryOperator that will act upon the provided InteractionContext to return the same but with the specified ZoneId .
combine(UnaryOperator)
Convenience method to combine UnaryOperator s, for example as per #switchUser(UserMemento) and #switchTimeZone(ZoneId) .
this implementation can result in heap pollution; better to use the #combine(Stream) overload . |
combine(Stream)
Convenience method to combine UnaryOperator s, for example as per #switchUser(UserMemento) and #switchTimeZone(ZoneId) . credit: https://stackoverflow.com/a/51065029/56880