Package com.ptsmods.mysqlw.collection
Class DbMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
com.ptsmods.mysqlw.collection.DbMap<K,V>
- All Implemented Interfaces:
DbCollection,Map<K,V>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) containsKeyAsync(Object key) booleancontainsValue(Object value) containsValueAsync(Object value) entrySet()@NotNull CompletableFuture<Set<Map.Entry<K,V>>> @NotNull DatabasegetDb()@NotNull BiFunction<String,DbCollection, K> @NotNull BiFunction<K,DbCollection, String> static <K,V> DbMap<K, V> getMap(@NotNull Database db, @NotNull String name, @NotNull BiFunction<K, DbCollection, String> keyToString, @NotNull BiFunction<V, DbCollection, String> valueToString, @NotNull BiFunction<String, DbCollection, K> keyFromString, @NotNull BiFunction<String, DbCollection, V> valueFromString) Gets a map from cache or creates a new one.static <K,V> DbMap<K, V> Gets a map from cache or creates a new one.getName()@NotNull StringgetTable()@NotNull BiFunction<String,DbCollection, V> @NotNull BiFunction<V,DbCollection, String> booleanisEmpty()keySet()@NotNull CompletableFuture<Set<K>>static <K,V> DbMap<K, V> parseString(Database db, String s, BiFunction<K, DbCollection, String> keyToString, BiFunction<V, DbCollection, String> valueToString, BiFunction<String, DbCollection, K> keyFromString, BiFunction<String, DbCollection, V> valueFromString) Parses a String representation of a DbMap into a DbMap.voidputAllAsync(@NotNull Map<? extends K, ? extends V> m) @Nullable CompletableFuture<V>removeAsync(Object key) <T> CompletableFuture<T>voidsetExecutor(Executor executor) intsize()toString()@NotNull Collection<V>values()@NotNull CompletableFuture<Collection<V>>Methods inherited from class java.util.AbstractMap
clone, equals, hashCodeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Method Details
-
parseString
public static <K,V> DbMap<K,V> parseString(Database db, String s, BiFunction<K, DbCollection, String> keyToString, BiFunction<V, DbCollection, String> valueToString, BiFunction<String, DbCollection, K> keyFromString, BiFunction<String, DbCollection, V> valueFromString) Parses a String representation of a DbMap into a DbMap.- Type Parameters:
K- The key type of this map.V- The value type of this map.- Parameters:
db- The database this map belongs to. Used when creating a new map.s- The String to parse.keyToString- The function used to convert a key object of this map into a String. Used when creating a new map.valueToString- The function used to convert a value object of this map into a String. Used when creating a new map.keyFromString- The function used to convert a String into a key object of this map. Used when creating a new map.valueFromString- The function used to convert a String into a value object of this map. Used when creating a new map.- Returns:
- A new DbMap or a cached one if available.
-
getMap
public static <K,V> DbMap<K,V> getMap(Database db, String name, Class<K> keyType, Class<V> valueType) Gets a map from cache or creates a new one.- Type Parameters:
K- The type of the keys in this map.V- The type of the values in this map.- Parameters:
db- The database this map belongs to. Used when creating a new map.name- The name of this map.keyType- The class of the type of the keys in this map, registered atDbCF. Used when creating a new map.valueType- The class of the type of the values in this map, registered atDbCF. Used when creating a new map.- Returns:
- A new DbMap or a cached one if available.
-
getMap
public static <K,V> DbMap<K,V> getMap(@NotNull @NotNull Database db, @NotNull @NotNull String name, @NotNull @NotNull BiFunction<K, DbCollection, String> keyToString, @NotNull @NotNull BiFunction<V, DbCollection, String> valueToString, @NotNull @NotNull BiFunction<String, DbCollection, K> keyFromString, @NotNull @NotNull BiFunction<String, DbCollection, V> valueFromString) Gets a map from cache or creates a new one.- Type Parameters:
K- The type of the keys in this map.V- The type of the values in this map.- Parameters:
db- The database this map belongs to. Used when creating a new map.name- The name of this map.keyToString- The function used to convert a key object of this map into a String. Used when creating a new map.valueToString- The function used to convert a value object of this map into a String. Used when creating a new map.keyFromString- The function used to convert a String into a key object of this map. Used when creating a new map.valueFromString- The function used to convert a String into a value object of this map. Used when creating a new map.- Returns:
- A new DbMap or a cached one if available.
-
setExecutor
-
getExecutor
-
runAsync
-
runAsync
-
size
public int size() -
sizeAsync
-
isEmpty
public boolean isEmpty() -
isEmptyAsync
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
containsKeyAsync
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V>
-
containsValueAsync
-
get
-
getAsync
-
put
-
putAsync
-
remove
-
removeAsync
-
putAll
-
putAllAsync
-
clear
public void clear() -
clearAsync
-
keySet
-
keySetAsync
-
values
-
valuesAsync
-
entrySet
-
entrySetAsync
-
toString
- Overrides:
toStringin classAbstractMap<K,V>
-
getDb
- Specified by:
getDbin interfaceDbCollection- Returns:
- The database this collection works with.
-
getTable
- Specified by:
getTablein interfaceDbCollection- Returns:
- The table this collection works with.
-
getName
- Specified by:
getNamein interfaceDbCollection- Returns:
- The name of this collection. Used to cache and parse from Strings.
-
getKeyToString
-
getValueToString
-
getKeyFromString
-
getValueFromString
-