Skip to content

Commit

Permalink
Allow developers to disable ChangeSet recording
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkArc committed May 14, 2016
1 parent f431615 commit eb1230e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Expand Up @@ -35,10 +35,24 @@ public class ArrayListHistory implements ChangeSet {

private final List<Change> changes = new ArrayList<Change>();

private boolean recordChanges = true;

@Override
public void add(Change change) {
checkNotNull(change);
changes.add(change);
if (recordChanges) {
changes.add(change);
}
}

@Override
public boolean isRecordingChanges() {
return recordChanges;
}

@Override
public void setRecordChanges(boolean recordChanges) {
this.recordChanges = recordChanges;
}

@Override
Expand Down
Expand Up @@ -36,6 +36,20 @@ public interface ChangeSet {
*/
void add(Change change);

/**
* Whether or not the ChangeSet is recording changes.
*
* @return whether or not the ChageSet is set to record changes
*/
boolean isRecordingChanges();

/**
* Tell the change set whether to record changes or not.
*
* @param recordChanges whether to record changes or not
*/
void setRecordChanges(boolean recordChanges);

/**
* Get a backward directed iterator that can be used for undo.
*
Expand Down

0 comments on commit eb1230e

Please sign in to comment.