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

com.daedafusion.security.common.impl.DefaultContext Maven / Gradle / Ivy

The newest version!
package com.daedafusion.security.common.impl;

import com.daedafusion.security.common.Context;
import org.apache.log4j.Logger;

import java.util.*;

/**
 * Created by mphilpot on 7/14/14.
 */
public class DefaultContext implements Context
{
    private static final Logger log = Logger.getLogger(DefaultContext.class);

    private Map> context;

    public DefaultContext()
    {
        context = new HashMap<>();
    }

    public DefaultContext(String key, String value)
    {
        this();
        context.put(key, Collections.singletonList(value));
    }

    @Override
    public Set getKeys()
    {
        return context.keySet();
    }

    @Override
    public List getContext(String key)
    {
        if(!context.containsKey(key))
        {
            context.put(key, new ArrayList());
        }

        return context.get(key);
    }

    @Override
    public void putContext(String key, List values)
    {
        context.put(key, values);
    }

    @Override
    public void addContext(String key, String value)
    {
        getContext(key).add(value);
    }

    @Override
    public String toString()
    {
        return "Context=" + context + '}';
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy