
javarepl.console.commands.Commands Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.console.commands;
import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.Sequences;
import com.googlecode.yadic.Container;
import javarepl.console.ConsoleConfig;
import static com.googlecode.totallylazy.Sequences.sequence;
public final class Commands {
private final Container context;
private Sequence> commands = Sequences.empty();
public Commands(Container context, ConsoleConfig config) {
this.context = context;
this.commands = config.commands;
}
public Sequence allCommands() {
return userCommands()
.join(commandInstances(sequence(
NotAValidCommand.class,
ShowResult.class,
EvaluateExpression.class)));
}
Sequence userCommands() {
return commandInstances(commands.cons(ShowHelp.class));
}
private Sequence commandInstances(Sequence> commands) {
return commands.map(context::create);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy