Group Builders

GroupBuilders allow you to programmatically create and modify the members of a given group. The following is an example of rebuilding a group from scratch.

   CommandGroup group = new CommandGroup("my-group");
   // get the builder
   GroupBuilder builder = group.getBuilder();

   // remove any existing members.
   builder.clear();

   // add some members that will be found from the
   // groups CommandConatiner.
   builder.add("my-command");
   builder.addInline("another-group");
   // add a separator member.
   builder.addSeparator();

   // add a command that will be used regardless of the
   // current command container.
   builder.add(anAnonymousCommand);

   // apply the changes
   builder.applyChanges();

Once either applyChanges() or discardChanges() is invoked the builder is discarded and you'll need to get a new instance to make further changes.