Class SynchronizableRepeater
- java.lang.Object
-
- org.ametys.plugins.repository.data.holder.values.SynchronizableRepeater
-
public final class SynchronizableRepeater extends Object
Wrapper for a synchronizable repeater.
Contains the repeater values and a mapping between stored entry positions and new ones.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSynchronizableRepeater.ModeThe entries write mode.
-
Field Summary
Fields Modifier and Type Field Description private List<Map<String,Object>>_entriesprivate SynchronizableRepeater.Mode_modeprivate Map<Integer,Integer>_positionsMappingprivate Set<Integer>_removedEntriesprivate List<Integer>_replacePositions
-
Constructor Summary
Constructors Modifier Constructor Description privateSynchronizableRepeater(List<Map<String,Object>> entries, Map<Integer,Integer> positionsMapping, List<Integer> replacePositions, Set<Integer> removedEntries, SynchronizableRepeater.Mode mode)privateSynchronizableRepeater(List<Map<String,Object>> entries, SynchronizableRepeater.Mode mode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SynchronizableRepeaterappendOrRemove(List<Map<String,Object>> newEntries, Set<Integer> removedEntries)Append and/or remove entries in a repeater.static SynchronizableRepeatercopy(SynchronizableRepeater repeater, List<Map<String,Object>> newEntries)Copy the provided repeater, optionally replacing entries with given ones.List<Map<String,Object>>getEntries()Returns the new repeater values.SynchronizableRepeater.ModegetMode()Returns the write mode for provided entries.Map<Integer,Integer>getPositionsMapping()Returns the mapping from stored positions to new ones.Set<Integer>getRemovedEntries()Returns the entries to be removed.List<Integer>getReplacePositions()Returns the positions of replacing entries.static SynchronizableRepeaterreplace(List<Map<String,Object>> entries, List<Integer> positions)Replace values in a repeater.static SynchronizableRepeaterreplaceAll(List<Map<String,Object>> entries, Map<Integer,Integer> positionsMapping)Replace all values in a repeater, optionally moving or removing entries.
-
-
-
Field Detail
-
_positionsMapping
private Map<Integer,Integer> _positionsMapping
-
_replacePositions
private List<Integer> _replacePositions
-
_removedEntries
private Set<Integer> _removedEntries
-
_mode
private SynchronizableRepeater.Mode _mode
-
-
Constructor Detail
-
SynchronizableRepeater
private SynchronizableRepeater(List<Map<String,Object>> entries, SynchronizableRepeater.Mode mode)
-
-
Method Detail
-
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
SynchronizableRepeaterin 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
SynchronizableRepeaterin 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
SynchronizableRepeaterin 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
public Map<Integer,Integer> getPositionsMapping()
Returns the mapping from stored positions to new ones.- Returns:
- the mapping from stored positions to new ones.
-
getReplacePositions
public List<Integer> getReplacePositions()
Returns the positions of replacing entries.- Returns:
- the positions of replacing entries.
-
getEntries
public List<Map<String,Object>> getEntries()
Returns the new repeater values.- Returns:
- the new repeater values.
-
getRemovedEntries
public Set<Integer> 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.
-
getMode
public SynchronizableRepeater.Mode getMode()
Returns the write mode for provided entries.- Returns:
- the write mode
-
-