This commit is contained in:
Him188moe 2019-08-18 20:33:01 +08:00
parent ceef31610b
commit 9ad7492790

View File

@ -5,18 +5,12 @@ import org.ini4j.Profile;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class MiraiMapSection extends ConcurrentHashMap<String, Object> implements MiraiConfigSection { public class MiraiMapSection extends ConcurrentHashMap<String, Object> implements MiraiConfigSection {
public Object get(String key){
return this.get(key,null);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> T get(String key, T defaultValue) { public <T> T get(String key, T defaultValue) {
if (key == null || key.isEmpty()){ if (key == null || key.isEmpty()){
@ -28,6 +22,17 @@ public class MiraiMapSection extends ConcurrentHashMap<String, Object> implement
return defaultValue; return defaultValue;
} }
@SuppressWarnings("unchecked")
public <T> T get(String key) {
if (key == null || key.isEmpty()) {
return null;
}
if (super.containsKey(key)) {
return (T) super.get(key);
}
return null;
}
public void set(String key, Object value){ public void set(String key, Object value){
this.put(key,value); this.put(key,value);
} }
@ -68,6 +73,10 @@ public class MiraiMapSection extends ConcurrentHashMap<String, Object> implement
return String.valueOf(this.get(key, defaultValue)); return String.valueOf(this.get(key, defaultValue));
} }
public Object getObject(String key) {
return this.get(key);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> List<T> asList(){ public <T> List<T> asList(){
return this.values().stream().map(a -> (T)(a)).collect(Collectors.toList()); return this.values().stream().map(a -> (T)(a)).collect(Collectors.toList());