public interface UndoManagerFactory
Modifier and Type | Method and Description |
---|---|
default <C> UndoManager<C> |
create(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply)
Creates an
UndoManager that tracks changes emitted from changeStream . |
default <C> UndoManager<C> |
create(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge)
Creates an
UndoManager that tracks and optionally merges changes emitted from changeStream . |
<C> UndoManager<C> |
create(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge,
Predicate<C> isIdentity)
Creates an
UndoManager that tracks and optionally merges changes emitted from changeStream . |
static UndoManagerFactory |
fixedSizeHistoryFactory(int capacity)
Creates a factory for
UndoManager s with bounded history. |
static <C> UndoManager<C> |
fixedSizeHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge,
int capacity)
Creates an
UndoManager with bounded history. |
static <C> UndoManager<C> |
fixedSizeHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge,
Predicate<C> isIdentity,
int capacity)
Creates an
UndoManager with bounded history. |
static <C> UndoManager<C> |
fixedSizeHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
int capacity)
Creates an
UndoManager with bounded history. |
static UndoManagerFactory |
unlimitedHistoryFactory()
Creates a factory for
UndoManager s with unlimited history. |
static <C> UndoManager<C> |
unlimitedHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply)
Creates an
UndoManager with unlimited history. |
static <C> UndoManager<C> |
unlimitedHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge)
Creates an
UndoManager with unlimited history. |
static <C> UndoManager<C> |
unlimitedHistoryUndoManager(EventStream<C> changeStream,
Function<? super C,? extends C> invert,
Consumer<C> apply,
BiFunction<C,C,Optional<C>> merge,
Predicate<C> isIdentity)
Creates an
UndoManager with unlimited history. |
static UndoManagerFactory |
zeroHistoryFactory()
Creates a factory for
UndoManager s with no history. |
static <C> UndoManager<C> |
zeroHistoryUndoManager(EventStream<C> changeStream)
Creates an
UndoManager with no history: all changes emitted from changeStream will be
immediately forgotten. |
default <C> UndoManager<C> create(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply)
UndoManager
that tracks changes emitted from changeStream
.C
- representation of a changeinvert
- Inverts a change, so that applying the inverted change (apply.accept(invert.apply(c))
)
has the effect of undoing the original change (c
). Inverting a change twice should
result in the original change (invert.apply(invert.apply(c)).equals(c)
).apply
- Used to apply a change. From the point of view of apply
, C
describes an action to be performed. Calling apply.accept(c)
must cause c
to be emitted from changeStream
.default <C> UndoManager<C> create(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge)
UndoManager
that tracks and optionally merges changes emitted from changeStream
.C
- representation of a changeinvert
- Inverts a change, so that applying the inverted change (apply.accept(invert.apply(c))
)
has the effect of undoing the original change (c
). Inverting a change twice should
result in the original change (invert.apply(invert.apply(c)).equals(c)
).apply
- Used to apply a change. From the point of view of apply
, C
describes an action to be performed. Calling apply.accept(c)
must cause c
to be emitted from changeStream
.merge
- Used to merge two subsequent changes into one.
Returns an empty Optional when the changes cannot or should not be merged.<C> UndoManager<C> create(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge, Predicate<C> isIdentity)
UndoManager
that tracks and optionally merges changes emitted from changeStream
.C
- representation of a changeinvert
- Inverts a change, so that applying the inverted change (apply.accept(invert.apply(c))
)
has the effect of undoing the original change (c
). Inverting a change twice should
result in the original change (invert.apply(invert.apply(c)).equals(c)
).apply
- Used to apply a change. From the point of view of apply
, C
describes an action to be performed. Calling apply.accept(c)
must cause c
to be emitted from changeStream
.merge
- Used to merge two subsequent changes into one.
Returns an empty Optional when the changes cannot or should not be merged.
If two changes "annihilate" (i.e. merge.apply(c1, c2).isPresen()
and
isIdentity.test(merge.apply(c1, c2).get())
are both true
), it should
be the case that one is inverse of the other (invert.apply(c1).equals(c2)
).isIdentity
- returns true for changes whose application would have no effect, thereby equivalent
to an identity function (Function.identity()
) on the underlying model.static <C> UndoManager<C> unlimitedHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply)
UndoManager
with unlimited history.
For description of parameters, see create(EventStream, Function, Consumer)
.static <C> UndoManager<C> unlimitedHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge)
UndoManager
with unlimited history.
For description of parameters, see create(EventStream, Function, Consumer, BiFunction)
.static <C> UndoManager<C> unlimitedHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge, Predicate<C> isIdentity)
UndoManager
with unlimited history.
For description of parameters, see create(EventStream, Function, Consumer, BiFunction, Predicate)
.static UndoManagerFactory unlimitedHistoryFactory()
UndoManager
s with unlimited history.static <C> UndoManager<C> fixedSizeHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, int capacity)
UndoManager
with bounded history.
When at full capacity, a new change will cause the oldest change to be forgotten.
For description of the remaining parameters, see create(EventStream, Function, Consumer)
.
capacity
- maximum number of changes the returned UndoManager can storestatic <C> UndoManager<C> fixedSizeHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge, int capacity)
UndoManager
with bounded history.
When at full capacity, a new change will cause the oldest change to be forgotten.
For description of the remaining parameters, see create(EventStream, Function, Consumer, BiFunction)
.
capacity
- maximum number of changes the returned UndoManager can storestatic <C> UndoManager<C> fixedSizeHistoryUndoManager(EventStream<C> changeStream, Function<? super C,? extends C> invert, Consumer<C> apply, BiFunction<C,C,Optional<C>> merge, Predicate<C> isIdentity, int capacity)
UndoManager
with bounded history.
When at full capacity, a new change will cause the oldest change to be forgotten.
For description of the remaining parameters, see create(EventStream, Function, Consumer, BiFunction, Predicate)
.
capacity
- maximum number of changes the returned UndoManager can storestatic UndoManagerFactory fixedSizeHistoryFactory(int capacity)
UndoManager
s with bounded history.
When at full capacity, a new change will cause the oldest change to be forgotten.static <C> UndoManager<C> zeroHistoryUndoManager(EventStream<C> changeStream)
UndoManager
with no history: all changes emitted from changeStream
will be
immediately forgotten. Therefore, the returned UndoManager will never be able to undo/redo
any change emitted from changeStream
.
However, the (imaginary) current position will keep advancing, so that one can still use
UndoManager.atMarkedPositionProperty()
to determine whether any change has occurred since the last
UndoManager.mark()
(e.g. since the last save).static UndoManagerFactory zeroHistoryFactory()
UndoManager
s with no history.zeroHistoryUndoManager(EventStream)