本文整理汇总了Java中javax.lang.model.element.ExecutableElement.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableElement.getAnnotation方法的具体用法?Java ExecutableElement.getAnnotation怎么用?Java ExecutableElement.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.ExecutableElement
的用法示例。
在下文中一共展示了ExecutableElement.getAnnotation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasWebMethods
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected boolean hasWebMethods(TypeElement element) {
if (element.getQualifiedName().toString().equals(Object.class.getName()))
return false;
WebMethod webMethod;
for (ExecutableElement method : ElementFilter.methodsIn(element.getEnclosedElements())) {
webMethod = method.getAnnotation(WebMethod.class);
if (webMethod != null) {
if (webMethod.exclude()) {
if (webMethod.operationName().length() > 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
"operationName", element.getQualifiedName(), method.toString()), method);
if (webMethod.action().length() > 0)
builder.processError(WebserviceapMessages.WEBSERVICEAP_INVALID_WEBMETHOD_ELEMENT_WITH_EXCLUDE(
"action", element.getQualifiedName(), method.toString()), method);
} else {
return true;
}
}
}
return false;//hasWebMethods(d.getSuperclass().getDeclaration());
}
示例2: JsonProperty
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public JsonProperty(String humanName, ExecutableElement element) {
this.methodName = element.getSimpleName().toString();
this.humanName = humanName;
this.element = element;
this.type = TypeName.get(element.getReturnType());
this.annotations = buildAnnotations(element);
JsonAdapter jsonAdapter = element.getAnnotation(JsonAdapter.class);
if (jsonAdapter != null) {
try {
jsonAdapter.value();
} catch (MirroredTypeException e) {
typeAdapter = e.getTypeMirror();
}
}
DefaultValue defaultValue = element.getAnnotation(DefaultValue.class);
if (defaultValue != null) {
this.defaultValue = defaultValue.value();
}
}
示例3: ModuleModel
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
* Creates a new module class model.
* @param ctx
* @param moduleElement type element representing the class of the module.
* @throws ModelException
*/
ModuleModel(ModelContext ctx, TypeElement moduleElement) throws ModelException {
if (!ctx.isModuleBase(moduleElement.asType()))
throw new ModelException("module must inherit from " + ModuleBase.class + ": " + moduleElement.getQualifiedName());
if (!moduleElement.getTypeParameters().isEmpty())
throw new ModelException("module cannot be generic: " + moduleElement.getQualifiedName());
element = moduleElement;
dataClass = ctx.getModuleDataClass(moduleElement);
simpleName = moduleElement.getSimpleName().toString();
fullName = moduleElement.getQualifiedName().toString();
packageName = fullName.substring(0, fullName.lastIndexOf('.'));
annotation = moduleElement.getAnnotation(AlvisNLPModule.class);
bundleName = annotation.docResourceBundle().isEmpty() ? fullName + "Doc" : annotation.docResourceBundle();
Map<String,ExecutableElement> methods = ctx.getMethodsByName(moduleElement);
for (ExecutableElement method : methods.values()) {
Param paramAnnotation = method.getAnnotation(Param.class);
if (paramAnnotation != null) {
params.add(new ParamModel(methods, method, paramAnnotation));
continue;
}
TimeThis timeAnnotation = method.getAnnotation(TimeThis.class);
if (timeAnnotation != null) {
timedMethods.add(new TimedMethodModel(ctx, method, timeAnnotation));
}
}
}
示例4: writeCreateSubscriberMethods
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private void writeCreateSubscriberMethods(BufferedWriter writer, List<ExecutableElement> methods,
String callPrefix, String myPackage) throws IOException {
for (ExecutableElement method : methods) {
List<? extends VariableElement> parameters = method.getParameters();
TypeMirror paramType = getParamTypeMirror(parameters.get(0), null);
TypeElement paramElement = (TypeElement) processingEnv.getTypeUtils().asElement(paramType);
String methodName = method.getSimpleName().toString();
String eventClass = getClassString(paramElement, myPackage) + ".class";
Subscribe subscribe = method.getAnnotation(Subscribe.class);
List<String> parts = new ArrayList<>();
parts.add(callPrefix + "(\"" + methodName + "\",");
String lineEnd = "),";
if (subscribe.priority() == 0 && !subscribe.sticky()) {
if (subscribe.threadMode() == ThreadMode.POSTING) {
parts.add(eventClass + lineEnd);
} else {
parts.add(eventClass + ",");
parts.add("ThreadMode." + subscribe.threadMode().name() + lineEnd);
}
} else {
parts.add(eventClass + ",");
parts.add("ThreadMode." + subscribe.threadMode().name() + ",");
parts.add(subscribe.priority() + ",");
parts.add(subscribe.sticky() + lineEnd);
}
writeLine(writer, 3, parts.toArray(new String[parts.size()]));
if (verbose) {
processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, "Indexed @Subscribe at " +
method.getEnclosingElement().getSimpleName() + "." + methodName +
"(" + paramElement.getSimpleName() + ")");
}
}
}
示例5: generateStaticMethodOverridesForRequestOptions
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private List<MethodAndStaticVar> generateStaticMethodOverridesForRequestOptions() {
List<ExecutableElement> staticMethodsThatReturnRequestOptions =
processorUtil.findStaticMethodsReturning(requestOptionsType, requestOptionsType);
List<MethodAndStaticVar> staticMethods = new ArrayList<>();
for (ExecutableElement element : staticMethodsThatReturnRequestOptions) {
if (element.getAnnotation(Deprecated.class) != null) {
continue;
}
staticMethods.add(generateStaticMethodEquivalentForRequestOptionsStaticMethod(element));
}
return staticMethods;
}
示例6: visitExecutable
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Override
public Void visitExecutable(ExecutableElement method, Object o) {
// Methods must be public
if (!method.getModifiers().contains(Modifier.PUBLIC))
return null;
if (processedMethod(method))
return null;
WebMethod webMethod = method.getAnnotation(WebMethod.class);
if (webMethod != null && webMethod.exclude())
return null;
SOAPBinding soapBinding = method.getAnnotation(SOAPBinding.class);
if (soapBinding == null && !method.getEnclosingElement().equals(typeElement)) {
if (method.getEnclosingElement().getKind().equals(ElementKind.CLASS)) {
soapBinding = method.getEnclosingElement().getAnnotation(SOAPBinding.class);
if (soapBinding != null)
builder.log("using " + method.getEnclosingElement() + "'s SOAPBinding.");
else {
soapBinding = new MySoapBinding();
}
}
}
boolean newBinding = false;
if (soapBinding != null) {
newBinding = pushSoapBinding(soapBinding, method, typeElement);
}
try {
if (shouldProcessMethod(method, webMethod)) {
processMethod(method, webMethod);
}
} finally {
if (newBinding) {
popSoapBinding();
}
}
return null;
}
示例7: getProperties
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private Map<String, ExecutableElement> getProperties(TypeElement targetClass) {
Map<String, ExecutableElement> elements = Maps.newLinkedHashMap();
for (ExecutableElement method : ElementFilter.methodsIn(targetClass.getEnclosedElements())) {
if (!method.getModifiers()
.contains(PRIVATE) && !method.getModifiers()
.contains(STATIC) && method.getAnnotation(InspectorIgnored.class) == null) {
elements.put(method.getSimpleName()
.toString(), method);
}
}
return elements;
}
示例8: getStaticMethodName
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
@Nullable
private static String getStaticMethodName(ExecutableElement element) {
GlideOption glideOption =
element.getAnnotation(GlideOption.class);
String result = glideOption != null ? glideOption.staticMethodName() : null;
return Strings.emptyToNull(result);
}
示例9: augmentProperties
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
* Explicitly add properties that elude reflection implicit strategy
* @param element
* @param props
*/
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.NPathComplexity"})
protected void augmentProperties(ExecutableElement element, Properties props) {
final TypeElement typedElement = (TypeElement) element.getEnclosingElement();
if (beanAnnotationClass != null && element.getAnnotation(beanAnnotationClass) != null) {
props.put("kind", "ENDPOINT");
} else {
props.put("kind", "BEAN");
props.put("entrypoint", typedElement.getQualifiedName().toString() + "::" + element.getSimpleName());
}
}
示例10: getGroupedProperties
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static Map<String, List<ExecutableElement>> getGroupedProperties(Map<String, ExecutableElement> propertyElements) {
Map<String, List<ExecutableElement>> groups = new HashMap<>();
for (ExecutableElement propertyElement : propertyElements.values()) {
NonVariant nonVariant = propertyElement.getAnnotation(NonVariant.class);
if (nonVariant != null) {
for (String groupName : nonVariant.value()) {
if (!groups.containsKey(groupName)) {
groups.put(groupName, new ArrayList<ExecutableElement>());
}
groups.get(groupName).add(propertyElement);
}
}
}
return groups;
}
示例11: countValueHandlerAnnotations
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static int countValueHandlerAnnotations(final ExecutableElement method) {
int count = 0;
for (final Class<? extends Annotation> annotationClass : AnnotationRegistry.VALUE_HANDLER_ANNOS) {
if (method.getAnnotation(annotationClass) != null) {
count++;
}
}
return count;
}
示例12: isListenerRequired
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static boolean isListenerRequired(ExecutableElement element) {
return element.getAnnotation(Optional.class) == null;
}
示例13: getOverrideType
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static int getOverrideType(ExecutableElement element) {
GlideOption glideOption =
element.getAnnotation(GlideOption.class);
return glideOption.override();
}
示例14: skipStaticMethod
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static boolean skipStaticMethod(ExecutableElement element) {
GlideOption glideOption =
element.getAnnotation(GlideOption.class);
return glideOption != null && glideOption.skipStaticMethod();
}
示例15: hasMethodAnnotation
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
public boolean hasMethodAnnotation(Class<? extends Annotation> a, ExecutableElement method) {
return method.getAnnotation(a)!=null;
}