private void appendOptionGroup ( StringBuilder sb , OptionGroup group ) { if ( ! group . isRequired ( ) ) { sb . append ( OPTIONAL_BRACKET_OPEN ) ; } List < Option > optList = new ArrayList <> ( group . getOptions ( ) ) ; if ( optList . size ( ) > 1 && getOptionComparator ( ) != null ) { optList . sort ( getOptionComparator ( ) ) ; } // for each option in the OptionGroup for ( Iterator < Option > it = optList . iterator ( ) ; it . hasNext ( ) ; ) { // whether the option is required or not is handled at group level appendOption ( sb , it . next ( ) , true ) ; if ( it . hasNext ( ) ) { sb . append ( " | " ) ; } } if ( ! group . isRequired ( ) ) { sb . append ( OPTIONAL_BRACKET_CLOSE ) ; } }
Appends the usage clause for an OptionGroup to a StringBuilder . The clause is wrapped in square brackets if the group is required . The display of the options is handled by appendOption .