Class CommandFactory


  • public class CommandFactory
    extends java.lang.Object
    The command factory can be used to instantiate a new command from a command name. The CommandLineClient uses this class to create and run commands by mapping a command argument to a corresponding Command class.
    • Constructor Summary

      Constructors 
      Constructor Description
      CommandFactory()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Command getInstance​(java.lang.String commandName)
      Maps the given command name to a corresponding Command class and instantiates it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static Command getInstance​(java.lang.String commandName)
        Maps the given command name to a corresponding Command class and instantiates it. The command name is camel-cased and mapped to a FQCN.

        Example: The command 'ls-remote' is mapped to the FQCN org.syncany.cli.LsRemoteCommand.

        Parameters:
        commandName - Command name, e.g. ls-remote or init
        Returns:
        Returns a Command instance, or null if the command name cannot be mapped to a class