forked from pcorless/icepdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Guillaume Tâche
committed
Jul 27, 2023
1 parent
675d33e
commit 7eb90b7
Showing
5 changed files
with
116 additions
and
26 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
core/core-awt/src/main/java/org/icepdf/core/CombinedMemento.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.icepdf.core; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* A memento composed of several mementos | ||
*/ | ||
public class CombinedMemento implements Memento { | ||
private final List<Memento> mementos; | ||
|
||
public CombinedMemento(final Memento... mementos) { | ||
this(Arrays.asList(mementos)); | ||
} | ||
|
||
public CombinedMemento(final List<Memento> mementos) { | ||
this.mementos = new ArrayList<>(mementos); | ||
Collections.reverse(this.mementos); | ||
} | ||
|
||
public List<Memento> getMementos() { | ||
return List.copyOf(mementos); | ||
} | ||
|
||
@Override | ||
public void restore() { | ||
mementos.forEach(Memento::restore); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters