mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-29 06:57:28 +02:00
Added Data#hasKey and Data#getKeys
This commit is contained in:
parent
155efc0cff
commit
fa4b083ab8
@ -1,5 +1,7 @@
|
||||
package net.minestom.server.data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class Data {
|
||||
@ -18,6 +20,21 @@ public class Data {
|
||||
return (T) data.getOrDefault(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @return true if the data contains the key, false otherwise
|
||||
*/
|
||||
public boolean hasKey(String key) {
|
||||
return data.containsKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unmodifiable set containing all keys
|
||||
*/
|
||||
public Set<String> getKeys() {
|
||||
return Collections.unmodifiableSet(data.keySet());
|
||||
}
|
||||
|
||||
public Data clone() {
|
||||
Data data = new Data();
|
||||
data.data = new ConcurrentHashMap<>(this.data);
|
||||
|
Loading…
Reference in New Issue
Block a user