本文整理汇总了Java中com.sun.mirror.declaration.MethodDeclaration.getAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java MethodDeclaration.getAnnotation方法的具体用法?Java MethodDeclaration.getAnnotation怎么用?Java MethodDeclaration.getAnnotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.mirror.declaration.MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.getAnnotation方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateSymbolAddresses
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
static void generateSymbolAddresses(final PrintWriter writer, final InterfaceDeclaration d) {
final Alias alias_annotation = d.getAnnotation(Alias.class);
final boolean aliased = alias_annotation != null && alias_annotation.postfix().length() > 0;
boolean foundNative = false;
for ( final MethodDeclaration method : d.getMethods() ) {
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
continue;
if ( !foundNative ) {
//writer.println("\t// " + d.getSimpleName());
writer.println("\tstatic final boolean " + CLGeneratorProcessorFactory.getExtensionName(d.getSimpleName()) + ";");
foundNative = true;
}
writer.print("\tstatic final long " + Utils.getFunctionAddressName(d, method) + " = CL.getFunctionAddress(");
if ( aliased )
writer.println("new String [] {\"" + Utils.getFunctionAddressName(d, method) + "\",\"" + method.getSimpleName() + alias_annotation.postfix() + "\"});");
else
writer.println("\"" + Utils.getFunctionAddressName(d, method) + "\");");
}
if ( foundNative )
writer.println();
}
示例2: printErrorCheckMethod
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
public void printErrorCheckMethod(final PrintWriter writer, final MethodDeclaration method, final String tabs) {
final Check check = method.getAnnotation(Check.class);
if ( check != null ) // Get the error code from an IntBuffer output parameter
writer.println(tabs + "Util.checkCLError(" + check.value() + ".get(" + check.value() + ".position()));");
else {
final Class return_type = Utils.getJavaType(method.getReturnType());
if ( return_type == int.class )
writer.println(tabs + "Util.checkCLError(__result);");
else {
boolean hasErrCodeParam = false;
for ( final ParameterDeclaration param : method.getParameters() ) {
if ( "errcode_ret".equals(param.getSimpleName()) && Utils.getJavaType(param.getType()) == IntBuffer.class ) {
hasErrCodeParam = true;
break;
}
}
if ( hasErrCodeParam )
throw new RuntimeException("A method is missing the @Check annotation: " + method.toString());
}
}
}
示例3: generateSymbolAddresses
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
boolean first = true;
for ( final MethodDeclaration method : d.getMethods() ) {
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
continue;
if ( first ) {
writer.println("\t// " + d.getSimpleName());
first = false;
}
writer.println("\tlong " + Utils.getFunctionAddressName(d, method) + ";");
}
}
示例4: generateClearsFromMethods
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
private static void generateClearsFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
for (MethodDeclaration method : interface_decl.getMethods()) {
if ( method.getAnnotation(Alternate.class) != null )
continue;
generateClearsFromParameters(writer, interface_decl, method);
}
}
示例5: generateCopiesFromMethods
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
private static void generateCopiesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
for (MethodDeclaration method : interface_decl.getMethods()) {
if ( method.getAnnotation(Alternate.class) != null )
continue;
generateCopiesFromParameters(writer, interface_decl, method);
}
}
示例6: generateReferencesFromMethods
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
private static void generateReferencesFromMethods(PrintWriter writer, InterfaceDeclaration interface_decl) {
for (MethodDeclaration method : interface_decl.getMethods()) {
if ( method.getAnnotation(Alternate.class) != null )
continue;
generateReferencesFromParameters(writer, interface_decl, method);
}
}
示例7: generateExtensionChecks
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
static void generateExtensionChecks(final PrintWriter writer, final InterfaceDeclaration d) {
Iterator<? extends MethodDeclaration> methods = d.getMethods().iterator();
if ( !methods.hasNext() )
return;
writer.println("\tprivate static boolean " + getExtensionSupportedName(d.getSimpleName()) + "() {");
writer.println("\t\treturn ");
boolean first = true;
while ( methods.hasNext() ) {
MethodDeclaration method = methods.next();
if ( method.getAnnotation(Alternate.class) != null )
continue;
if ( !first )
writer.println(" &");
else
first = false;
final boolean optional = method.getAnnotation(Optional.class) != null;
writer.print("\t\t\t");
if ( optional )
writer.print('(');
writer.print(Utils.getFunctionAddressName(d, method) + " != 0");
if ( optional )
writer.print(" || true)");
}
writer.println(";");
writer.println("\t}");
writer.println();
}
示例8: generateSymbolAddresses
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
public static void generateSymbolAddresses(PrintWriter writer, InterfaceDeclaration d) {
boolean first = true;
for ( final MethodDeclaration method : d.getMethods() ) {
if ( method.getAnnotation(Alternate.class) != null || method.getAnnotation(Reuse.class) != null )
continue;
if ( first ) {
writer.println("\t// " + d.getSimpleName());
first = false;
}
writer.println("\tint " + Utils.getFunctionAddressName(d, method) + ";");
}
}
示例9: visitMethodDeclaration
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
/**
* Stores information about getter and setter methods annotated with
* {@link Accessor} and {@link Mutator}. This includes thrown exceptions,
* setter parameters annotated with {@link MutatorParameter}, and required
* imports. The {@link SPAnnotationProcessor} takes this information and
* generates
* {@link SPPersisterHelper#commitProperty(SPObject, String, Object, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
* and
* {@link SPPersisterHelper#findProperty(SPObject, String, ca.sqlpower.dao.session.SessionPersisterSuperConverter)}
* methods.
*
* @param d
* The {@link MethodDeclaration} of the method to visit.
*/
public void visitMethodDeclaration(MethodDeclaration d) {
Accessor accessorAnnotation = d.getAnnotation(Accessor.class);
Mutator mutatorAnnotation = d.getAnnotation(Mutator.class);
Transient transientAnnotation = d.getAnnotation(Transient.class);
TypeMirror type = null;
if (!d.getDeclaringType().equals(typeDecl)) return;
if (accessorAnnotation != null && transientAnnotation == null) {
type = d.getReturnType();
} else if (mutatorAnnotation != null && transientAnnotation == null) {
type = d.getParameters().iterator().next().getType();
} else {
return;
}
String methodName = d.getSimpleName();
Class<?> c = null;
try {
c = SPAnnotationProcessorUtils.convertTypeMirrorToClass(type);
if (!propertiesToAccess.containsKey(methodName) && accessorAnnotation != null) {
propertiesToAccess.put(methodName, c);
if (accessorAnnotation.persistOnlyIfNonNull()) {
propertiesToPersistOnlyIfNonNull.add(
SPAnnotationProcessorUtils.convertMethodToProperty(methodName));
}
accessorAdditionalInfo.putAll(
methodName, Arrays.asList(accessorAnnotation.additionalInfo()));
} else if (!propertiesToMutate.containsKey(methodName) && mutatorAnnotation != null) {
for (ReferenceType refType : d.getThrownTypes()) {
Class<? extends Exception> thrownType =
(Class<? extends Exception>) Class.forName(refType.toString());
mutatorThrownTypes.put(methodName, thrownType);
mutatorImports.put(methodName, thrownType.getName());
}
propertiesToMutate.put(methodName, c);
mutatorImports.put(methodName, c.getName());
for (ParameterDeclaration pd : d.getParameters()) {
MutatorParameter mutatorParameterAnnotation =
pd.getAnnotation(MutatorParameter.class);
if (mutatorParameterAnnotation != null) {
Class<?> extraParamType =
SPAnnotationProcessorUtils.convertTypeMirrorToClass(pd.getType());
mutatorExtraParameters.put(methodName,
new MutatorParameterObject(
extraParamType,
pd.getSimpleName(),
mutatorParameterAnnotation.value()));
mutatorImports.put(methodName, extraParamType.getName());
}
}
}
} catch (ClassNotFoundException e) {
valid = false;
e.printStackTrace();
}
}
示例10: hasMethodAnnotation
import com.sun.mirror.declaration.MethodDeclaration; //导入方法依赖的package包/类
public boolean hasMethodAnnotation(Class<? extends Annotation> a, MethodDeclaration method) {
return method.getAnnotation(a)!=null;
}