Created
March 23, 2015 19:12
-
-
Save Romain-P/f113b01af0056c9c44eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.heat.world.commands; | |
| import com.google.common.collect.ImmutableList; | |
| import com.google.common.collect.ImmutableMap; | |
| import lombok.Getter; | |
| import org.heat.shared.stream.ImmutableCollectors; | |
| import java.util.List; | |
| import java.util.Map; | |
| import java.util.function.Function; | |
| /** | |
| * Managed by romain on 11/03/2015. | |
| */ | |
| @Getter | |
| public class DefaultCommandTree implements CommandTree{ | |
| private final String name; | |
| private final Command command; | |
| private final Map<String, CommandArg> arguments; | |
| private final Map<String, CommandTree> subCommandTrees; | |
| private final Map<String, CommandArg> requiredArguments; | |
| private final List<Class> conditions; | |
| private final List<String> aliases; | |
| public DefaultCommandTree(String name, | |
| Command command, | |
| Map<String, CommandArg> arguments, | |
| Map<String, CommandTree> subCommandTrees, | |
| List<Class> conditions, | |
| List<String> aliases) { | |
| this.name = name; | |
| this.command = command; | |
| this.arguments = ImmutableMap.copyOf(arguments); | |
| this.subCommandTrees = ImmutableMap.copyOf(subCommandTrees); | |
| this.conditions = ImmutableList.copyOf(conditions); | |
| this.aliases = ImmutableList.copyOf(aliases); | |
| this.requiredArguments = arguments.values() | |
| .stream() | |
| .filter(CommandArg::isRequired) | |
| .collect(ImmutableCollectors.toMap(CommandArg::getLabel, Function.identity())); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment