Class StringPrefixMap<V extends Serializable>
- Type Parameters:
V- The type of the value that is to be stored.
- All Implemented Interfaces:
Serializable,Map<String,,V> PrefixMap<V>
- Direct Known Subclasses:
ASCIIPrefixMap
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()The prefixmap will be empty after this call returns.static voidconfigureKryo(Object kryoInstance) This is used to configure the provided Kryo instance if Kryo serialization is desired.booleancontainsKey(Object key) booleanReturnstrueif this map contains an exact mapping for the specified prefix.booleancontainsValue(Object value) entrySet()Return the value of theexactmatching prefix.Returns List of all matches that have a value.Return the value of the longest matching prefix.Return the value of theshortestmatching prefix.keySet()Stored the specified value as the result for the specified prefix.Removes the mapping for a prefix if present.intsize()values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface nl.basjes.collections.PrefixMap
containsPrefix, containsPrefix, get, getAllMatches, getAllMatches, getLongestMatch, getLongestMatch, getShortestMatch, getShortestMatch, isEmpty, putAll, remove
-
Constructor Details
-
StringPrefixMap
public StringPrefixMap(boolean caseSensitive)
-
-
Method Details
-
configureKryo
This is used to configure the provided Kryo instance if Kryo serialization is desired. The expected type here is Object because otherwise the Kryo library becomes a mandatory dependency on any project that uses Yauaa.- Parameters:
kryoInstance- The instance of com.esotericsoftware.kryo.Kryo that needs to be configured.
-
containsPrefix
Description copied from interface:PrefixMapReturns
trueif this map contains an exact mapping for the specified prefix.Note that implementations may be constructed to match either case sensitive or case insensitive.
- Specified by:
containsPrefixin interfacePrefixMap<V extends Serializable>- Parameters:
prefix- prefix whose presence in this prefixmap is to be checked- Returns:
trueif this map contains an the exact mapping for the specified prefix.
-
put
Description copied from interface:PrefixMapStored the specified value as the result for the specified prefix.
If for the specified prefix previously a value was present then the old value is replaced with the new value and the old value is returned.
Note that implementations may be constructed to store this value for either case sensitive or case insensitive matching during retrieval.
- Specified by:
putin interfaceMap<String,V extends Serializable> - Specified by:
putin interfacePrefixMap<V extends Serializable>- Parameters:
prefix- prefix with which the specified value is to be associatedvalue- value to be associated with the specified prefix- Returns:
- the previous value of the specified
prefix, ornullif there was no mapping forprefix.
-
size
public int size()- Specified by:
sizein interfaceMap<String,V extends Serializable> - Specified by:
sizein interfacePrefixMap<V extends Serializable>- Returns:
- the number of prefix-value mappings in this prefixmap
-
clear
public void clear()Description copied from interface:PrefixMapThe prefixmap will be empty after this call returns.- Specified by:
clearin interfaceMap<String,V extends Serializable> - Specified by:
clearin interfacePrefixMap<V extends Serializable>
-
remove
Description copied from interface:PrefixMapRemoves the mapping for a prefix if present.
Note that implementations may be constructed to remove either case sensitive (only this exact value) or case insensitive (all case variations).
- Specified by:
removein interfacePrefixMap<V extends Serializable>- Parameters:
prefix- prefix whose mapping is to be removed from the prefixmap- Returns:
- the previous value associated with
prefix(may be null).
-
get
Description copied from interface:PrefixMapReturn the value of the
exactmatching prefix.The value returned is the stored prefix for which is true:
input.equals(prefix).Note that implementations may be constructed to match either case sensitive or case insensitive.
- Specified by:
getin interfacePrefixMap<V extends Serializable>- Parameters:
prefix- The string for which we need value of the stored prefix- Returns:
- The value, null if not found.
-
getShortestMatch
Description copied from interface:PrefixMapReturn the value of the
shortestmatching prefix.The value returned is the shortest stored prefix for which is true:
input.startsWith(prefix).Note that implementations may be constructed to match either case sensitive or case insensitive.
- Specified by:
getShortestMatchin interfacePrefixMap<V extends Serializable>- Parameters:
input- The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.- Returns:
- The value, null if not found.
-
getLongestMatch
Description copied from interface:PrefixMapReturn the value of the longest matching prefix.
The value returned is the longest stored prefix for which is true:
input.startsWith(prefix).Note that implementations may be constructed to match either case sensitive or case insensitive.
- Specified by:
getLongestMatchin interfacePrefixMap<V extends Serializable>- Parameters:
input- The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.- Returns:
- The value, null if not found.
-
getAllMatches
Description copied from interface:PrefixMapReturns List of all matches that have a value.
The list contains all non-null values for the prefix values where this is true:
input.startsWith(prefix).Note that implementations may be constructed to match either case sensitive or case insensitive.
- Specified by:
getAllMatchesin interfacePrefixMap<V extends Serializable>- Parameters:
input- The string (iterator of Unicode CodePoints) for which we need value of the stored prefix.- Returns:
- The list of values, an empty List if nothing is found.
-
entrySet
- Specified by:
entrySetin interfaceMap<String,V extends Serializable>
-
containsKey
- Specified by:
containsKeyin interfaceMap<String,V extends Serializable> - Specified by:
containsKeyin interfacePrefixMap<V extends Serializable>
-
containsValue
- Specified by:
containsValuein interfaceMap<String,V extends Serializable> - Specified by:
containsValuein interfacePrefixMap<V extends Serializable>
-
keySet
- Specified by:
keySetin interfaceMap<String,V extends Serializable> - Specified by:
keySetin interfacePrefixMap<V extends Serializable>
-
values
- Specified by:
valuesin interfaceMap<String,V extends Serializable> - Specified by:
valuesin interfacePrefixMap<V extends Serializable>
-