public < E extends Enum < E > & FieldType > E nextField ( Class < E > clazz , UserFieldDataType type ) { for ( String name : m_names [ type . ordinal ( ) ] ) { int i = NumberHelper . getInt ( m_counters . get ( name ) ) + 1 ; try { E e = Enum . valueOf ( clazz , name + i ) ; m_counters . put ( name , Integer . valueOf ( i ) ) ; return e ; } catch ( IllegalArgumentException ex ) { // try the next name } } // no more fields available throw new IllegalArgumentException ( "No fields for type " + type + " available" ) ; }
Generate the next available field for a user defined field .