All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy