M - the type of data to manage.K - the type of the data key.public class MappedListDecorator<M,K> extends ArrayList<M> implements List<M>
List interface, that relies on an internal Map to track existing data by the key
K.
The "raison d'ĂȘtre" of that class is to simplify the JAXB data model by putting properties that appear to be lists and managing the add/replace feature internally and at the same location.
| Modifier and Type | Field and Description |
|---|---|
protected Map<K,M> |
dataLookup
The lookup map that maps the data to its key.
|
modCount| Constructor and Description |
|---|
MappedListDecorator(Class<M> modelType,
List<M> model,
Function<M,K> getModelId)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
M element) |
boolean |
add(M e) |
boolean |
addAll(Collection<? extends M> c) |
boolean |
addAll(int index,
Collection<? extends M> c) |
void |
addOrReplaceData(M model)
Adds or replaces the given
model, given that its key K is not yet registered in the current
mapping or not. |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
boolean |
equals(Object o) |
M |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<M> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<M> |
listIterator() |
ListIterator<M> |
listIterator(int index) |
M |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
M |
set(int index,
M element) |
int |
size() |
List<M> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
clone, ensureCapacity, forEach, removeIf, removeRange, replaceAll, sort, spliterator, trimToSizetoStringfinalize, getClass, notify, notifyAll, wait, wait, waitreplaceAll, sort, spliteratorparallelStream, removeIf, streampublic MappedListDecorator(Class<M> modelType, List<M> model, Function<M,K> getModelId)
modelType - the type of the model to manage.model - the decorated model list.getModelId - a function that provides a model key of type K given a model of type M.public void add(int index,
M element)
public boolean add(M e)
public boolean addAll(Collection<? extends M> c)
public boolean addAll(int index,
Collection<? extends M> c)
public void addOrReplaceData(M model)
model, given that its key K is not yet registered in the current
mapping or not.model - the model to add or update.public void clear()
public boolean contains(Object o)
public boolean containsAll(Collection<?> c)
containsAll in interface Collection<M>containsAll in interface List<M>containsAll in class AbstractCollection<M>public boolean equals(Object o)
equals in interface Collection<M>equals in interface List<M>equals in class AbstractList<M>public M get(int index)
public int hashCode()
hashCode in interface Collection<M>hashCode in interface List<M>hashCode in class AbstractList<M>public int indexOf(Object o)
public boolean isEmpty()
public int lastIndexOf(Object o)
lastIndexOf in interface List<M>lastIndexOf in class ArrayList<M>public ListIterator<M> listIterator()
listIterator in interface List<M>listIterator in class ArrayList<M>public ListIterator<M> listIterator(int index)
listIterator in interface List<M>listIterator in class ArrayList<M>public M remove(int index)
public boolean remove(Object o)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public int size()
public Object[] toArray()
Copyright © 2020. All rights reserved.