public static < T extends Enum < ? > > String getEnumValuesAsString ( Class < T > enumClass ) { //ScoringStrategy[] vals = ScoringStrategy.values(); T [ ] vals = enumClass . getEnumConstants ( ) ; StringBuilder str = new StringBuilder ( ) ; if ( vals . length == 1 ) { str . append ( vals [ 0 ] . name ( ) ) ; } else if ( vals . length > 1 ) { for ( int i = 0 ; i < vals . length - 1 ; i ++ ) { str . append ( vals [ i ] . name ( ) ) ; str . append ( ", " ) ; } str . append ( "or " ) ; str . append ( vals [ vals . length - 1 ] . name ( ) ) ; } return str . toString ( ) ; }
Constructs a comma - separated list of values for an enum .