protected int getOptionIndex ( final Object option ) { int optionCount = 0 ; List < ? > options = getOptions ( ) ; if ( options != null ) { for ( Object obj : getOptions ( ) ) { if ( obj instanceof OptionGroup ) { List < ? > groupOptions = ( ( OptionGroup ) obj ) . getOptions ( ) ; int groupIndex = groupOptions . indexOf ( option ) ; if ( groupIndex != - 1 ) { return optionCount + groupIndex ; } optionCount += groupOptions . size ( ) ; } else if ( Util . equals ( option , obj ) ) { return optionCount ; } else { optionCount ++ ; } } } return - 1 ; }
Retrieves the index of the given option . The index is not necessarily the index of the option in the options list as there may be options nested in OptionGroups .