/** * Issue a compilation error and abandon the processing of this class. This does not prevent * the processing of other classes. * * @param msg The error message. * @param e The element at which the error occurred. */ private void abortWithError(String msg, Element e) { reportError(msg, e); throw new AbortProcessingException(); }
/** * This method retrieves the {@link TypeMirror} from an annotation. This is a bit tricky in annotation * processing because the class are not loaded so you can't retrieve class objects from the annotation directly. * See: http://blog.retep.org/2009/02/13/getting-class-values-from-annotations-in-an-annotationprocessor/ * * @param validated the {@link Validated} annotation. * @param type the TypeElement which is used only for error logging. * @return the TypeMirror. */ private TypeMirror getTypeMirrorFromAnnotation(Validated validated, TypeElement type) { try { // This should always throw an exception validated.factory(); } catch (MirroredTypeException e) { return e.getTypeMirror(); } reportError("Retrieving class information from annotation did not throw an exception something is wrong.", type); throw new AbortProcessingException(); } }