public static TestConstructor findSingle ( Class < ? > cls ) { final TestConstructor [ ] constructors = findAll ( cls ) ; if ( constructors . length == 0 ) { throw new IllegalStateException ( cls . getName ( ) + " requires at least 1 public constructor" ) ; } else if ( constructors . length == 1 ) { return constructors [ 0 ] ; } else { throw new IllegalStateException ( "Class " + cls . getName ( ) + " has too many parameterized constructors. " + "Should only be 1 (with enum variations)." ) ; } }
Find the parameterized constructor of cls if there is one or the default constructor if there isn t .