*
* @return A possibly non-empty set of constraint check errors, never null.
*/
private Set<ConstraintCheckError> checkPayloadAttribute(TypeElement element) {
ExecutableElement payloadMethod = getMethod( element, "payload" );
if ( payloadMethod == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_PAYLOAD_MEMBER" )
);
}
DeclaredType type = getComponentTypeOfArrayReturnType( payloadMethod );
if ( type == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
boolean typeArgumentIsWildcardWithPayloadExtendsBound = validateWildcardBounds(
type.getTypeArguments().get( 0 ),
annotationApiHelper.getDeclaredTypeByName( BeanValidationTypes.PAYLOAD ),
null
);
if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsWildcardWithPayloadExtendsBound ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
if ( !isEmptyArray( payloadMethod.getDefaultValue() ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY" )
);
}