mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
contextholder添加get方法
This commit is contained in:
@@ -63,6 +63,11 @@ public class ContextHolder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(ContextKey<T> parameter) {
|
||||
return (T) Optional.ofNullable(this.params.get(parameter)).map(Supplier::get).orElse(null);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getOrThrow(ContextKey<T> parameter) {
|
||||
Supplier<T> object = (Supplier<T>) this.params.get(parameter);
|
||||
|
||||
Reference in New Issue
Block a user