
os.rio-core.0.6.0.source-code.CommandModule Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2014 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.rio;
import java.util.Map;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
/**
* @author [email protected] (Marcio Endo)
*/
public abstract class CommandModule {
private final Map> executableMap = Maps.newHashMap();
protected abstract void configure();
protected ExecuteCommand execute(String command) {
return new ExecuteCommand(command);
}
protected Optional> get(String name) {
Class extends Command> maybeCommand = executableMap.get(name);
return Optional.> fromNullable(maybeCommand);
}
protected CommandModule init() {
executableMap.clear();
configure();
return this;
}
protected class ExecuteCommand {
private final String command;
public ExecuteCommand(String command) {
this.command = command;
}
public void with(Class extends Command> clazz) {
executableMap.put(command, clazz);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy