public abstract class XAbstractProcessor extends AbstractProcessor implements CommonUtil
Differences with AbstractProcessor:
SupportedAnnotation to define supported annotation by Class
instead of String| 限定符和类型 | 类和说明 |
|---|---|
protected static class |
XAbstractProcessor.Assert<T>
ASSERT
|
protected class |
XAbstractProcessor.Log |
CommonUtil.ActionE0<E extends Exception>, CommonUtil.FuncE0<R,E extends Exception>| 限定符和类型 | 字段和说明 |
|---|---|
protected Elements |
elements |
protected Filer |
filer |
protected boolean |
isDebug |
protected Messager |
messager |
protected Types |
types |
processingEnv| 构造器和说明 |
|---|
XAbstractProcessor() |
| 限定符和类型 | 方法和说明 |
|---|---|
protected <T> XAbstractProcessor.Assert<T> |
assertDo(Callable<T> task) |
protected XAbstractProcessor.Assert<Void> |
assertDo(CommonUtil.ActionE0<?> task) |
protected <T> XAbstractProcessor.Assert<T> |
assertNonNull(T t) |
protected XAbstractProcessor.Assert<Void> |
assertThat(boolean b) |
protected <T> XAbstractProcessor.Assert<T> |
assertThat(T t,
boolean b) |
protected <T> XAbstractProcessor.Assert<T> |
assertThat(T t,
java.util.function.Predicate<T> b) |
protected <T> XAbstractProcessor.Assert<T> |
assertType(Object o,
Class<T> clz) |
protected XAbstractProcessor.Log |
debug()
LOG
|
protected XAbstractProcessor.Log |
error() |
Set<String> |
getSupportedAnnotationTypes()
If the processor class is annotated with
SupportedAnnotation or
SupportedAnnotationTypes, return an unmodifiable set with the same
set of strings as the annotation. |
protected void |
handleAssert(Runnable task)
Override this method to do something for
AssertException. |
void |
init(ProcessingEnvironment processingEnv) |
boolean |
process(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv)
|
abstract boolean |
processActual(Set<? extends TypeElement> annotations,
RoundEnvironment roundEnv)
Processes a set of annotation types on type elements originating from the
prior round and returns whether or not these annotation types are claimed
by this processor.
|
protected XAbstractProcessor.Log |
warning() |
getCompletions, getSupportedOptions, getSupportedSourceVersion, isInitializedclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitensureFileSystem, getStackTraceString, throwAsUncheck, uncatch, uncatch, uncheck, uncheckprotected Types types
protected Elements elements
protected Messager messager
protected Filer filer
protected boolean isDebug
public void init(ProcessingEnvironment processingEnv)
init 在接口中 Processorinit 在类中 AbstractProcessorpublic final boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
process 在接口中 Processorprocess 在类中 AbstractProcessorpublic abstract boolean processActual(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws AssertException
true is returned, the annotation types are claimed and subsequent
processors will not be asked to process them; if false is returned,
the annotation types are unclaimed and subsequent processors may be asked
to process them. A processor may always return the same boolean value or
may vary the result based on chosen criteria.
The input set will be empty if the processor supports "*" and the root elements have no annotations. A Processor must gracefully handle an empty set of annotations.
annotations - the annotation types requested to be processedroundEnv - environment for information about the current and prior
roundAssertException - throw the AssertException to quit the process
directlyassertThat(boolean),
handleAssert(Runnable)protected void handleAssert(Runnable task)
AssertException.task - task who will throw AssertExceptionpublic Set<String> getSupportedAnnotationTypes()
SupportedAnnotation or
SupportedAnnotationTypes, return an unmodifiable set with the same
set of strings as the annotation. If the class is not so annotated, an
empty set is returned.getSupportedAnnotationTypes 在接口中 ProcessorgetSupportedAnnotationTypes 在类中 AbstractProcessorprotected <T> XAbstractProcessor.Assert<T> assertThat(T t, java.util.function.Predicate<T> b)
protected <T> XAbstractProcessor.Assert<T> assertThat(T t, boolean b)
protected XAbstractProcessor.Assert<Void> assertThat(boolean b)
protected <T> XAbstractProcessor.Assert<T> assertType(Object o, Class<T> clz)
protected <T> XAbstractProcessor.Assert<T> assertNonNull(T t)
protected <T> XAbstractProcessor.Assert<T> assertDo(Callable<T> task)
protected XAbstractProcessor.Assert<Void> assertDo(CommonUtil.ActionE0<?> task)
protected XAbstractProcessor.Log debug()
protected XAbstractProcessor.Log warning()
protected XAbstractProcessor.Log error()
Copyright © 2018. All rights reserved.