Interface CMap<K,V>
-
- All Superinterfaces:
CBaseState<java.util.Map<K,V>>
,CBaseVerifier<java.util.Map<K,V>>
,CBaseWaiter<java.util.Map<K,V>>
,CMapState<K,V>
,CMapVerifier<K,V>
,CObjectState<java.util.Map<K,V>>
,CObjectVerifier<java.util.Map<K,V>,CMapState<K,V>>
,java.util.Map<K,V>
,java.io.Serializable
- All Known Implementing Classes:
CHashMap
,CLinkedMap
,CTestData
public interface CMap<K,V> extends java.util.Map<K,V>, CMapVerifier<K,V>, CMapState<K,V>
This interfaceCMap
uses to facilitate Map related functionality for testing. We hope to extend this class with more useful methods.- See Also:
Collection
,CHashMap
,CLinkedMap
,CSet
,CList
-
-
Field Summary
-
Fields inherited from interface org.catools.common.extensions.states.interfaces.CBaseState
serialVersionUID
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default CSet<java.util.Map.Entry<K,V>>
asSet()
Returns aCSet
view of the mappings contained in this map.default CHashMap<K,V>
getAll(java.util.function.BiPredicate<K,V> predicate)
Returns all element from map which matched thepredicate
otherwise return emptyCHashMap
.default CSet<K>
getAllKeys(java.util.function.Predicate<V> predicate)
ReturnsCList
of key of elements from map which matched thepredicate
otherwise return empty list.default CList<V>
getAllValues(java.util.function.Predicate<K> predicate)
ReturnsCList
of value of elements from map which matched thepredicate
otherwise return empty list.default CMap<K,V>
getBaseValue()
get theCMap
of itemsdefault java.util.Map.Entry<K,V>
getFirst(java.util.function.BiPredicate<K,V> predicate)
Returns CCliItemCollection first element from map which matched thepredicate
otherwise throwsNoSuchElementException
.default K
getFirstKeyByValue(java.util.function.Predicate<V> predicate)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise throwNoSuchElementException
.default K
getFirstKeyByValue(V value)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise throwNoSuchElementException
.default K
getFirstKeyByValueOrElse(java.util.function.Predicate<V> predicate, K otherKey)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise returnotherKey
.default K
getFirstKeyByValueOrElse(V value, K otherKey)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise returnotherKey
.default K
getFirstKeyByValueOrNull(java.util.function.Predicate<V> predicate)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise return null.default K
getFirstKeyByValueOrNull(V value)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise return null.default V
getFirstValueByKey(java.util.function.Predicate<K> predicate)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise throwNoSuchElementException
.default V
getFirstValueByKey(K key)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise throwNoSuchElementException
.default V
getFirstValueByKeyOrElse(java.util.function.Predicate<K> predicate, V otherValue)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue.default V
getFirstValueByKeyOrElse(K key, V otherValue)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue.default V
getFirstValueByKeyOrNull(java.util.function.Predicate<K> predicate)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue.default V
getFirstValueByKeyOrNull(K key)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue.default CLinkedMap<K,V>
getSortedMap(java.util.Comparator<java.util.Map.Entry<K,V>> comparator)
Sorts the CMap according to the order induced by the specified comparator.default CSet<K>
keySet()
Returns aCSet
view of the keys contained in this map.default CList<V>
values()
Returns aCSet
view of the keys contained in this map.-
Methods inherited from interface org.catools.common.extensions.verify.interfaces.CBaseVerifier
_useWaiter, _verify, _verify, _verify, _verify, _verify, _verify, _verifyWithDefaultMessage, _verifyWithDefaultMessage, getDefaultMessage, getEntityDescription
-
Methods inherited from interface org.catools.common.extensions.wait.interfaces.CBaseWaiter
getDefaultWaitInSeconds, getDefaultWaitIntervalInMilliSeconds
-
Methods inherited from interface org.catools.common.extensions.states.interfaces.CMapState
contains, contains, containsAll, containsAll, containsNone, containsNone, emptyOrContains, emptyOrContains, emptyOrNotContains, emptyOrNotContains, isEqual, isEqual, isNotEmpty, notContains, notContains, notContainsAll, sizeEquals, sizeIsGreaterThan, sizeIsGreaterThanOrEqual, sizeIsLessThan, sizeIsLessThanOrEqual
-
Methods inherited from interface org.catools.common.extensions.verify.interfaces.CMapVerifier
_toState, verifyContains, verifyContains, verifyContains, verifyContains, verifyContainsAll, verifyContainsAll, verifyContainsNone, verifyContainsNone, verifyEmptyOrContains, verifyEmptyOrContains, verifyEmptyOrContains, verifyEmptyOrContains, verifyEmptyOrNotContains, verifyEmptyOrNotContains, verifyEmptyOrNotContains, verifyEmptyOrNotContains, verifyEquals, verifyEquals, verifyIsEmpty, verifyIsEmpty, verifyIsNotEmpty, verifyIsNotEmpty, verifyNotContains, verifyNotContains, verifyNotContains, verifyNotContains, verifyNotContainsAll, verifyNotContainsAll, verifySizeEquals, verifySizeEquals, verifySizeIsGreaterThan, verifySizeIsGreaterThan, verifySizeIsGreaterThanOrEqual, verifySizeIsGreaterThanOrEqual, verifySizeIsLessThan, verifySizeIsLessThan, verifySizeIsLessThanOrEqual, verifySizeIsLessThanOrEqual
-
Methods inherited from interface org.catools.common.extensions.states.interfaces.CObjectState
equalsAny, equalsAny, equalsNone, equalsNone, isNotNull, isNull, notEqual, test
-
Methods inherited from interface org.catools.common.extensions.verify.interfaces.CObjectVerifier
verifyEqualsAny, verifyEqualsAny, verifyEqualsNone, verifyEqualsNone, verifyIsNotNull, verifyIsNotNull, verifyIsNull, verifyIsNull, verifyNotEquals, verifyNotEquals
-
-
-
-
Method Detail
-
getBaseValue
default CMap<K,V> getBaseValue()
get theCMap
of items- Specified by:
getBaseValue
in interfaceCBaseState<K>
- Returns:
- the CMap to be used in related interface
-
asSet
default CSet<java.util.Map.Entry<K,V>> asSet()
Returns aCSet
view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's ownremove
operation, or through thesetValue
operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via theIterator.remove
,CSet.remove
,removeAll
,retainAll
andclear
operations. It does not support theadd
oraddAll
operations.- Returns:
- CSet of the mappings contained in this map
-
getAll
default CHashMap<K,V> getAll(java.util.function.BiPredicate<K,V> predicate)
Returns all element from map which matched thepredicate
otherwise return emptyCHashMap
. The preferred alternative to this method isgetFirst(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllValues(Predicate)
,getAllKeys(Predicate)
.- Parameters:
predicate
- tests against key and value- Returns:
CHashMap
with all elements which matched thepredicate
-
getAllKeys
default CSet<K> getAllKeys(java.util.function.Predicate<V> predicate)
ReturnsCList
of key of elements from map which matched thepredicate
otherwise return empty list. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllValues(Predicate)
.- Parameters:
predicate
- tests against value- Returns:
CList
of key of elements from map which matched thepredicate
otherwise return empty list.
-
getAllValues
default CList<V> getAllValues(java.util.function.Predicate<K> predicate)
ReturnsCList
of value of elements from map which matched thepredicate
otherwise return empty list. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against key- Returns:
CList
of value of elements from map which matched thepredicate
otherwise return empty list.
-
getFirst
default java.util.Map.Entry<K,V> getFirst(java.util.function.BiPredicate<K,V> predicate)
Returns CCliItemCollection first element from map which matched thepredicate
otherwise throwsNoSuchElementException
. The preferred alternative to this method isgetAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllValues(Predicate)
,getAllKeys(Predicate)
.- Parameters:
predicate
- tests against key and value- Returns:
- the non-
null
value described by thisOptional
- Throws:
java.util.NoSuchElementException
- if no value is present
-
getFirstKeyByValue
default K getFirstKeyByValue(V value)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise throwNoSuchElementException
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
value
- value to search for- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null. - Throws:
java.util.NoSuchElementException
- in case no match found
-
getFirstKeyByValue
default K getFirstKeyByValue(java.util.function.Predicate<V> predicate)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise throwNoSuchElementException
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against value- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null. - Throws:
java.util.NoSuchElementException
- in case no match found
-
getFirstKeyByValueOrElse
default K getFirstKeyByValueOrElse(V value, K otherKey)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise returnotherKey
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
value
- value to search forotherKey
- to return if no match found- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null.
-
getFirstKeyByValueOrElse
default K getFirstKeyByValueOrElse(java.util.function.Predicate<V> predicate, K otherKey)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise returnotherKey
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against valueotherKey
- to return if no match found- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null.
-
getFirstKeyByValueOrNull
default K getFirstKeyByValueOrNull(V value)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise return null. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
value
- value to search for- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null.
-
getFirstKeyByValueOrNull
default K getFirstKeyByValueOrNull(java.util.function.Predicate<V> predicate)
Returns CCliItemCollection key of first element from map which its value match thepredicate
otherwise return null. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getAllValues(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against value- Returns:
- CCliItemCollection key of first element from map which matched the
predicate
otherwise return null.
-
getFirstValueByKey
default V getFirstValueByKey(K key)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise throwNoSuchElementException
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
key
- the key we are searching for- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null. - Throws:
java.util.NoSuchElementException
- if not match found
-
getFirstValueByKey
default V getFirstValueByKey(java.util.function.Predicate<K> predicate)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise throwNoSuchElementException
. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against key- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null. - Throws:
java.util.NoSuchElementException
- if not match found
-
getFirstValueByKeyOrElse
default V getFirstValueByKeyOrElse(K key, V otherValue)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
key
- the key we are searching forotherValue
- to return in case if predicate did not match any value- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null.
-
getFirstValueByKeyOrElse
default V getFirstValueByKeyOrElse(java.util.function.Predicate<K> predicate, V otherValue)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against keyotherValue
- to return in case if predicate did not match any value- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null.
-
getFirstValueByKeyOrNull
default V getFirstValueByKeyOrNull(K key)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
key
- the key we are searching for- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null.
-
getFirstValueByKeyOrNull
default V getFirstValueByKeyOrNull(java.util.function.Predicate<K> predicate)
Returns CCliItemCollection value of first element from map which its key match thepredicate
otherwise return otherValue. The preferred alternative to this method isgetFirst(BiPredicate)
,getAll(BiPredicate)
,getFirstValueByKey(Predicate)
getFirstKeyByValue(Predicate)
getAllKeys(Predicate)
.- Parameters:
predicate
- tests against key- Returns:
- CCliItemCollection value of first element from map which matched the
predicate
otherwise return null.
-
getSortedMap
default CLinkedMap<K,V> getSortedMap(java.util.Comparator<java.util.Map.Entry<K,V>> comparator)
Sorts the CMap according to the order induced by the specified comparator. Key and Value of all elements in the map must be mutually comparable using the specified comparator (that is,c.compare(e1, e2)
must not throw CCliItemCollectionClassCastException
for any elementse1
ande2
in the list).This sort is guaranteed to be stable: equal elements will not be reordered as CCliItemCollection result of the sort.
The specified list must be modifiable, but need not be resizable.
- Parameters:
comparator
- the comparator to determine the order of the list. Anull
value indicates that the elements' natural ordering should be used.- Returns:
CLinkedMap
sorted based on defined comparator- Throws:
java.lang.ClassCastException
- if the list contains elements that are not mutually comparable using the specified comparator.java.lang.UnsupportedOperationException
- if the specified list's list-iterator does not support theset
operation.java.lang.IllegalArgumentException
- (optional) if the comparator is found to violate theComparator
contract- See Also:
ArrayList.sort(Comparator)
-
-