@@ -488,7 +488,9 @@ public int compareTo( CommandRegistry cr ) {
488
488
* (parent and sub registries) with the same name (eg the command name must be unique).
489
489
* <p>
490
490
* If the command was already registered to another registry (that is not part of the
491
- * hierarchy of the calling registry), it is unregistered from it first.
491
+ * hierarchy of the calling registry), it is unregistered from it first.<br>
492
+ * If it failed to be registered to this registry, it is not unregistered from the previous
493
+ * registry.
492
494
* <p>
493
495
* Only main commands can be registered. Subcommands will simply fail to be added.
494
496
*
@@ -551,6 +553,48 @@ public boolean registerCommand( ICommand command ) throws NullPointerException {
551
553
552
554
}
553
555
556
+ /**
557
+ * Attempts to register all the commands in the given collection to this registry.
558
+ * <p>
559
+ * After the method returns, all the commands that did not fail to be registered
560
+ * will be registered to this registry.<br>
561
+ * They will also be unregistered from their previous registry, if any.
562
+ * <p>
563
+ * Commands that fail to be registered are unchanged.
564
+ *
565
+ * @param commands The commands to be registered.
566
+ */
567
+ public void registerAllCommands ( Collection <ICommand > commands ) {
568
+
569
+ for ( ICommand command : commands ) { // Register each command.
570
+
571
+ try {
572
+ registerCommand ( command );
573
+ } catch ( NullPointerException e ) {
574
+ LOG .error ( "Command collection included null." , e );
575
+ }
576
+
577
+ }
578
+
579
+ }
580
+
581
+ /**
582
+ * Attempts to register all the commands in the given registry to this registry.
583
+ * <p>
584
+ * After the method returns, all the commands that did not fail to be registered
585
+ * will be registered to this registry.<br>
586
+ * They will also be unregistered from the given registry.
587
+ * <p>
588
+ * Commands that fail to be registered are unchanged.
589
+ *
590
+ * @param commands The commands to be registered.
591
+ */
592
+ public void registerAllCommands ( CommandRegistry registry ) {
593
+
594
+ registerAllCommands ( registry .getRegisteredCommands () );
595
+
596
+ }
597
+
554
598
/**
555
599
* Unregisters a command from this registry.
556
600
*
0 commit comments