This repository has been archived on 2022-02-11. You can view files and clone it, but cannot push or open issues or pull requests.
2021-12-11 18:18:39 +01:00
|
|
|
package dev.kske.undoredo.core;
|
2021-12-07 19:13:51 +01:00
|
|
|
|
|
|
|
/**
|
2022-02-11 09:48:34 +01:00
|
|
|
* Base interface for changes to be registered in a change manager.
|
2021-12-22 15:51:33 +01:00
|
|
|
*
|
2021-12-07 19:13:51 +01:00
|
|
|
* @author Maximilian Käfer
|
|
|
|
* @since 0.0.1
|
|
|
|
*/
|
|
|
|
public interface Change {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Performs the action implemented by this change.
|
|
|
|
*
|
|
|
|
* @since 0.0.1
|
|
|
|
*/
|
|
|
|
void apply();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Inverts this change.
|
2021-12-22 15:51:33 +01:00
|
|
|
*
|
2021-12-07 19:13:51 +01:00
|
|
|
* @implSpec This method is not supposed to alter the state of this change, but rather to create
|
|
|
|
* a new complementary change.
|
|
|
|
* @return the inverted change
|
|
|
|
* @since 0.0.1
|
|
|
|
*/
|
|
|
|
Change invert();
|
|
|
|
|
|
|
|
/**
|
2021-12-22 15:51:33 +01:00
|
|
|
* @apiNote If this method returns {@code true} when adding this change to a change manager, it
|
|
|
|
* will be discarded immediately and therefore can be garbage collected.
|
2021-12-07 19:13:51 +01:00
|
|
|
* @return whether the application of this change would result in an identical state
|
|
|
|
* @since 0.0.1
|
|
|
|
*/
|
|
|
|
boolean isIdentity();
|
|
|
|
}
|