org.zodiac.fastorm.rdb.events.DefaultEventContext Maven / Gradle / Ivy
The newest version!
package org.zodiac.fastorm.rdb.events;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import org.zodiac.sdk.toolkit.util.ClassUtil;
class DefaultEventContext extends ConcurrentHashMap implements EventContext {
private static final long serialVersionUID = 289423644005337613L;
@Override
public Object get(String key) {
return get((Object) key);
}
@Override
public Optional get(ContextKey key) {
return Optional.ofNullable(get(key.getKey()))
.map(ClassUtil::cast);
}
@Override
public EventContext set(ContextKey key, T value) {
put(key.getKey(), value);
return this;
}
@Override
public EventContext set(String key, T value) {
put(key, value);
return this;
}
@Override
public EventContext set(ContextKeyValue>... keyValue) {
for (ContextKeyValue> contextKeyValue : keyValue) {
put(contextKeyValue.getKey(),contextKeyValue.getValue());
}
return this;
}
}