Class SynchronizableRepeater
java.lang.Object
org.ametys.plugins.repository.data.holder.values.SynchronizableRepeater
Wrapper for a synchronizable repeater.
Contains the repeater values and a mapping between stored entry positions and new ones.
Contains the repeater values and a mapping between stored entry positions and new ones.
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SynchronizableRepeater
Append and/or remove entries in a repeater.static SynchronizableRepeater
Copy the provided repeater, optionally replacing entries with given ones.Returns the new repeater values.getMode()
Returns the write mode for provided entries.Returns the mapping from stored positions to new ones.getPreviousPosition
(int newPosition) Retrieves the previous position of the given one from the repeater mappingReturns the entries to be removed.Returns the positions of replacing entries.static SynchronizableRepeater
Replace values in a repeater.static SynchronizableRepeater
Replace all values in a repeater, optionally moving or removing entries.
-
Method Details
-
replaceAll
public static SynchronizableRepeater replaceAll(List<Map<String, Object>> entries, Map<Integer, Integer> positionsMapping) Replace all values in a repeater, optionally moving or removing entries. Entries not present in the mapping will be removed.- Parameters:
entries
- the new repeater values.positionsMapping
- a mapping from stored positions to new ones. No mapping for an existing entry means removal. A null mapping means the identity mapping.- Returns:
- a
SynchronizableRepeater
in replace mode.
-
replace
public static SynchronizableRepeater replace(List<Map<String, Object>> entries, List<Integer> positions) Replace values in a repeater.- Parameters:
entries
- the new repeater values.positions
- the positions of the provided entries in the repeater. A null List means replacing the first entries.- Returns:
- a
SynchronizableRepeater
in replace mode.
-
appendOrRemove
public static SynchronizableRepeater appendOrRemove(List<Map<String, Object>> newEntries, Set<Integer> removedEntries) Append and/or remove entries in a repeater.- Parameters:
newEntries
- the entries to be appended to the repeater.removedEntries
- the entries to be removed from the repeater.- Returns:
- a
SynchronizableRepeater
in append mode.
-
copy
public static SynchronizableRepeater copy(SynchronizableRepeater repeater, List<Map<String, Object>> newEntries) Copy the provided repeater, optionally replacing entries with given ones.- Parameters:
repeater
- the SynchronizableRepeater to copynewEntries
- the new entries values- Returns:
- a new SynchronizableRepeater
-
getPositionsMapping
Returns the mapping from stored positions to new ones.- Returns:
- the mapping from stored positions to new ones.
-
getReplacePositions
Returns the positions of replacing entries.- Returns:
- the positions of replacing entries.
-
getEntries
Returns the new repeater values.- Returns:
- the new repeater values.
-
getRemovedEntries
Returns the entries to be removed.
Only relevant for append mode.
For replace mode, removed entries are carried trough the positions mapping.- Returns:
- the new repeater values.
-
getPreviousPosition
Retrieves the previous position of the given one from the repeater mapping- Parameters:
newPosition
- the new entry position- Returns:
- the previous entry position
-
getMode
Returns the write mode for provided entries.- Returns:
- the write mode
-