private boolean hasPublicEmptyConstructor ( DeclaredType type ) { Element element = type . asElement ( ) ; List < ? extends Element > containing = element . getEnclosedElements ( ) ; for ( Element e : containing ) { if ( e . getKind ( ) == ElementKind . CONSTRUCTOR ) { ExecutableElement c = ( ExecutableElement ) e ; if ( ( c . getParameters ( ) == null || c . getParameters ( ) . isEmpty ( ) ) && c . getModifiers ( ) . contains ( javax . lang . model . element . Modifier . PUBLIC ) ) { return true ; } } } return false ; }
Checks if an public empty constructor is available