Package com.guokr.simbase

Source Code of com.guokr.simbase.SimRegistry

package com.guokr.simbase;

import java.util.HashMap;
import java.util.Map;

import com.guokr.simbase.errors.SimCommandException;

public class SimRegistry {

    private Map<String, SimCommand> registry = new HashMap<String, SimCommand>();

    public void add(String key, SimCommand cmd) {
        registry.put(key, cmd);
    }

    public SimCommand get(String key) {
        SimCommand command = registry.get(key);
        if (command == null) {
            throw new SimCommandException(String.format("Unknown command '%s'", key));
        }
        return command;
    }
}
TOP

Related Classes of com.guokr.simbase.SimRegistry

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.