Class ListMap<K,T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<T>
-
- org.fugerit.java.core.util.collection.ListMap<K,T>
-
- Type Parameters:
K
- the class type for the keyT
- the class type for the value
- All Implemented Interfaces:
Serializable
,Iterable<T>
,Collection<T>
,List<T>
- Direct Known Subclasses:
ListMapStringKey
public class ListMap<K,T> extends AbstractList<T> implements Serializable
A implementation of java.util.List interface able to save a collections in a Map too.
- Author:
- Fugerit
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
ADD_MODE_DEFAULT
static int
ADD_MODE_LOOSE
static int
ADD_MODE_STRICT
-
Fields inherited from class java.util.AbstractList
modCount
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, T element)
T
get(int index)
T
get(Object key)
Get an object by key Delegate for getMap().get().int
getAddMode()
Get the object adding policy for this List.Iterator<K>
getKeyIterator()
Return iteration over KeysKeyMapper<K,T>
getKeyMapper()
Get the KeyMapper for this ListMapMap<K,T>
getMap()
The list underlying MapT
getProperty(K key)
Alias for get(key)T
remove(int index)
T
set(int index, T element)
void
setAddMode(int addMode)
Set the object adding policy for this List ListMap has an underlying Map, the policy states of duplicate keys are allowedvoid
setKeyMapper(KeyMapper<K,T> keyMapper)
Set the KeyMapper for this ListMapint
size()
-
Methods inherited from class java.util.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subList
-
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
-
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
-
-
-
-
Field Detail
-
ADD_MODE_STRICT
public static final int ADD_MODE_STRICT
- See Also:
- Constant Field Values
-
ADD_MODE_LOOSE
public static final int ADD_MODE_LOOSE
- See Also:
- Constant Field Values
-
ADD_MODE_DEFAULT
public static final int ADD_MODE_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
getKeyMapper
public KeyMapper<K,T> getKeyMapper()
Get the KeyMapper for this ListMap- Returns:
- the KeyMapper
-
setKeyMapper
public void setKeyMapper(KeyMapper<K,T> keyMapper)
Set the KeyMapper for this ListMap- Parameters:
keyMapper
- the KeyMapper
-
add
public void add(int index, T element)
-
remove
public T remove(int index)
-
get
public T get(int index)
-
size
public int size()
- Specified by:
size
in interfaceCollection<K>
- Specified by:
size
in interfaceList<K>
- Specified by:
size
in classAbstractCollection<T>
-
get
public T get(Object key)
Get an object by key Delegate for getMap().get().- Parameters:
key
- the key- Returns:
- the value
-
getProperty
public T getProperty(K key)
Alias for get(key)- Parameters:
key
- the key- Returns:
- the value
-
getKeyIterator
public Iterator<K> getKeyIterator()
Return iteration over Keys- Returns:
- iterations over keys
-
getMap
public Map<K,T> getMap()
The list underlying Map- Returns:
- The key/value Map for this ListMap
-
getAddMode
public int getAddMode()
Get the object adding policy for this List.- Returns:
- the AddMode
-
setAddMode
public void setAddMode(int addMode)
Set the object adding policy for this List ListMap has an underlying Map, the policy states of duplicate keys are allowed- Parameters:
addMode
- the policy
-
-