本文整理汇总了Java中org.jboss.jandex.MethodInfo类的典型用法代码示例。如果您正苦于以下问题:Java MethodInfo类的具体用法?Java MethodInfo怎么用?Java MethodInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodInfo类属于org.jboss.jandex包,在下文中一共展示了MethodInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private void process(Map<String, String> paths, String className, List<AnnotationInstance> annotations)
throws MojoExecutionException {
AnnotationInstance rootAnnotation = getRootAnnotation(annotations);
processRootAnnotation(paths, className, rootAnnotation);
String pathInClass = getRootPath(rootAnnotation);
for (AnnotationInstance annotation : annotations) {
AnnotationValue value = annotation.value();
if (value != null) {
if (annotation.target().kind() != (AnnotationTarget.Kind.CLASS)) {
MethodInfo annotatedMethod = annotation.target().asMethod();
String path = new String();
path = addHttpVerb(path, annotatedMethod);
path = addProducer(path, annotatedMethod);
path = addConsumer(path, annotatedMethod);
String fullPath = path.concat(
pathInClass != null ? pathInClass.concat("/").concat(value.asString()) : value.asString());
addInPaths(paths, className, fullPath);
}
}
}
}
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:25,代码来源:PathAnalyzer.java
示例2: processRootAnnotation
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private void processRootAnnotation(Map<String, String> paths, String className, AnnotationInstance rootAnnotation)
throws MojoExecutionException {
if (rootAnnotation == null)
return;
List<MethodInfo> methods = rootAnnotation.target().asClass().methods();
for (MethodInfo method : methods)
if (!containsPathAnnotation(method)) {
String httpVerb = getHttpVerb(method);
if (httpVerb != null) {
String path = httpVerb;
path = addProducer(path, method);
path = addConsumer(path, method);
path = path.concat("/").concat(getRootPath(rootAnnotation));
addInPaths(paths, className, path);
}
}
}
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:18,代码来源:PathAnalyzer.java
示例3: getHttpVerb
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private String getHttpVerb(MethodInfo method) {
getLog().debug("Getting http verb from method:");
getLog().debug(method.name());
List<AnnotationInstance> methodAnnotations = method.annotations();
for (AnnotationInstance annotation : methodAnnotations) {
DotName annotationName = annotation.name();
if (!annotationName.equals(PATH_ANNOTATION)) {
if (annotationName.equals(GET_ANNOTATION))
return "GET ";
if (annotationName.equals(POST_ANNOTATION))
return "POST ";
if (annotationName.equals(PUT_ANNOTATION))
return "PUT ";
if (annotationName.equals(DELETE_ANNOTATION))
return "DELETE ";
if (annotationName.equals(OPTIONS_ANNOTATION))
return "OPTIONS ";
if (annotationName.equals(HEAD_ANNOTATION))
return "HEAD ";
}
}
return null;
}
开发者ID:ContaAzul,项目名称:jaxrs-path-analyzer,代码行数:25,代码来源:PathAnalyzer.java
示例4: createDefaultCallback
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private void createDefaultCallback(Class callbackTypeClass,
DotName callbackTypeName,
String callbackClassName,
Map<Class<?>, String> callbacksByClass) {
for ( AnnotationInstance callback : getLocalBindingContext().getIndex().getAnnotations( callbackTypeName ) ) {
MethodInfo methodInfo = (MethodInfo) callback.target();
validateMethod( methodInfo, callbackTypeClass, callbacksByClass, true );
if ( methodInfo.declaringClass().name().toString().equals( callbackClassName ) ) {
if ( methodInfo.args().length != 1 ) {
throw new PersistenceException(
String.format(
"Callback method %s must have exactly one argument defined as either Object or %s in ",
methodInfo.name(),
getEntityName()
)
);
}
callbacksByClass.put( callbackTypeClass, methodInfo.name() );
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:EntityClass.java
示例5: createCallback
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private void createCallback(Class callbackTypeClass,
DotName callbackTypeName,
Map<Class<?>, String> callbacksByClass,
ClassInfo callbackClassInfo,
boolean isListener) {
Map<DotName, List<AnnotationInstance>> annotations = callbackClassInfo.annotations();
List<AnnotationInstance> annotationInstances = annotations.get( callbackTypeName );
if ( annotationInstances == null ) {
return;
}
for ( AnnotationInstance callbackAnnotation : annotationInstances ) {
MethodInfo methodInfo = (MethodInfo) callbackAnnotation.target();
validateMethod( methodInfo, callbackTypeClass, callbacksByClass, isListener );
callbacksByClass.put( callbackTypeClass, methodInfo.name() );
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:EntityClass.java
示例6: findTransientFieldAndMethodNames
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
/**
* Populates the sets of transient field and method names.
*/
private void findTransientFieldAndMethodNames() {
List<AnnotationInstance> transientMembers = classInfo.annotations().get( JPADotNames.TRANSIENT );
if ( transientMembers == null ) {
return;
}
for ( AnnotationInstance transientMember : transientMembers ) {
AnnotationTarget target = transientMember.target();
if ( target instanceof FieldInfo ) {
transientFieldNames.add( ( (FieldInfo) target ).name() );
}
else {
transientMethodNames.add( ( (MethodInfo) target ).name() );
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:ConfiguredClass.java
示例7: getMemberAnnotations
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
public static Map<DotName, List<AnnotationInstance>> getMemberAnnotations(ClassInfo classInfo, String name) {
if ( classInfo == null ) {
throw new IllegalArgumentException( "classInfo cannot be null" );
}
if ( name == null ) {
throw new IllegalArgumentException( "name cannot be null" );
}
Map<DotName, List<AnnotationInstance>> annotations = new HashMap<DotName, List<AnnotationInstance>>();
for ( List<AnnotationInstance> annotationList : classInfo.annotations().values() ) {
for ( AnnotationInstance instance : annotationList ) {
String targetName = null;
if ( instance.target() instanceof FieldInfo ) {
targetName = ( (FieldInfo) instance.target() ).name();
}
else if ( instance.target() instanceof MethodInfo ) {
targetName = ( (MethodInfo) instance.target() ).name();
}
if ( targetName != null && name.equals( targetName ) ) {
addAnnotationToMap( instance, annotations );
}
}
}
return annotations;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:JandexHelper.java
示例8: determineAccessTypeByIdPlacement
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private static AccessType determineAccessTypeByIdPlacement(List<AnnotationInstance> idAnnotations) {
AccessType accessType = null;
for ( AnnotationInstance annotation : idAnnotations ) {
AccessType tmpAccessType;
if ( annotation.target() instanceof FieldInfo ) {
tmpAccessType = AccessType.FIELD;
}
else if ( annotation.target() instanceof MethodInfo ) {
tmpAccessType = AccessType.PROPERTY;
}
else {
throw new AnnotationException( "Invalid placement of @Id annotation" );
}
if ( accessType == null ) {
accessType = tmpAccessType;
}
else {
if ( !accessType.equals( tmpAccessType ) ) {
throw new AnnotationException( "Inconsistent placement of @Id annotation within hierarchy " );
}
}
}
return accessType;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:EntityHierarchyBuilder.java
示例9: targetEquals
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
/**
* @param t1 can't be null
* @param t2 can't be null
*/
public static boolean targetEquals(AnnotationTarget t1, AnnotationTarget t2) {
if ( t1 == t2 ) {
return true;
}
if ( t1 != null && t2 != null ) {
if ( t1.getClass() == t2.getClass() ) {
if ( t1.getClass() == ClassInfo.class ) {
return ( (ClassInfo) t1 ).name().equals( ( (ClassInfo) t2 ).name() );
}
else if ( t1.getClass() == MethodInfo.class ) {
return ( (MethodInfo) t1 ).name().equals( ( (MethodInfo) t2 ).name() );
}
else {
return ( (FieldInfo) t1 ).name().equals( ( (FieldInfo) t2 ).name() );
}
}
}
return false;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:25,代码来源:MockHelper.java
示例10: processMethodResource
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
protected void processMethodResource(final DeploymentUnit deploymentUnit, final MethodInfo methodInfo, final String lookup) throws DeploymentUnitProcessingException {
SubsystemService service = getService();
String moduleName = getService().moduleNameFromJndi(lookup);
if (moduleName != null) {
savePerDeploymentModuleName(deploymentUnit, moduleName, service.vendorKey());
ROOT_LOGGER.scannedResourceLookup(lookup, moduleName);
} else {
ROOT_LOGGER.ignoringResourceLookup(lookup, getService().jndiNames());
}
}
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:11,代码来源:DriverScanDependencyProcessor.java
示例11: buildMethodDef
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
static String buildMethodDef(MethodInfo method) {
StringBuilder builder = new StringBuilder();
// Method Parameters
builder.append("(");
for (org.jboss.jandex.Type type : method.parameters()) {
builder.append(buildTypeDef(type.name().toString()));
}
builder.append(")");
// Method Return Type
if (method.returnType().kind().equals(org.jboss.jandex.Type.Kind.VOID)) {
builder.append("V");
} else {
builder.append(buildTypeDef(method.returnType().name().toString()));
}
return builder.toString();
}
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:20,代码来源:ClientServiceFactory.java
示例12: executeMethod
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
/**
* Execute the method annotated with specified class. If the annotated method has parameter signature {@link Session} it
* will create a session a pass it as parameter.
*
* @param annotatedInstance - The annotated class
* @param name - The name of the method annotated
* @param classLoader - The class loader
* @throws Exception
*/
private <T extends Annotation> void executeMethod(final AnnotationInstance annotatedInstance, final DotName name, final ClassLoader classLoader)
throws Exception {
ClassInfo classInfo = (ClassInfo) annotatedInstance.target();
classInfo.annotations().entrySet()
.stream()
.filter(annotationMap -> annotationMap.getKey().equals(name))
.flatMap(annotationInstanceList -> annotationInstanceList.getValue().stream())
.filter(methodInstance -> methodInstance.target() instanceof MethodInfo)
.map(methodTarget -> methodTarget.target())
.map(MethodInfo.class::cast)
.forEach(t -> {
executeMethodWithParameters(annotatedInstance, classLoader, t, (ClassInfo) annotatedInstance.target());
});
}
开发者ID:wildfly-extras,项目名称:db-bootstrap,代码行数:25,代码来源:DbBootstrapScanDetectorProcessor.java
示例13: verify
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
@Override
public final AssertionResult verify(final ClassInfo info) {
boolean ok = true;
final StringBuffer sb = new StringBuffer("Class " + info.name() + " has final methods:\n");
final List<MethodInfo> methodInfos = info.methods();
for (final MethodInfo methodInfo : methodInfos) {
if (Modifier.isFinal(methodInfo.flags())) {
ok = false;
sb.append(methodInfo.toString());
sb.append("\n");
}
}
if (ok) {
return AssertionResult.OK;
}
return new AssertionResult(sb.toString());
}
开发者ID:fuinorg,项目名称:units4j,代码行数:22,代码来源:RuleClassHasNoFinalMethods.java
示例14: validParameters
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private boolean validParameters(final MethodInfo method, final StringBuilder sb) {
boolean ok = true;
final Map<Integer, List<AnnotationInstance>> map = Utils.createParameterAnnotationMap(method);
final List<Type> params = method.parameters();
for (int i = 0; i < params.size(); i++) {
final Type param = params.get(i);
if (param.kind() != Kind.PRIMITIVE) {
final List<AnnotationInstance> annotations = map.get(i);
if ((annotations == null) || !contains(annotations, notNullFqn, nullableFqn)) {
ok = false;
sb.append(method.declaringClass());
sb.append("\t");
sb.append(method);
sb.append("\t");
sb.append("Parameter #" + i + " (" + params.get(i).name() + ")\n");
}
}
}
return ok;
}
开发者ID:fuinorg,项目名称:units4j,代码行数:24,代码来源:RuleMethodHasNullabilityInfo.java
示例15: createParameterAnnotationMap
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
/**
* Create a map for parameter annotations. The key id the index (zero based) of the parameter and the
* value is a list of all annotations.
*
* @param method
* Method to create a map for.
*
* @return Map with parameter index (key) and list of annotations (value).
*/
public static Map<Integer, List<AnnotationInstance>> createParameterAnnotationMap(
final MethodInfo method) {
final Map<Integer, List<AnnotationInstance>> result = new HashMap<>();
for (AnnotationInstance ai : method.annotations()) {
final AnnotationTarget at = ai.target();
if (at.kind() == AnnotationTarget.Kind.METHOD_PARAMETER) {
final MethodParameterInfo mp = at.asMethodParameter();
final int pos = (int) mp.position();
List<AnnotationInstance> list = result.get(pos);
if (list == null) {
list = new ArrayList<>();
result.put(pos, list);
}
list.add(ai);
}
}
return result;
}
开发者ID:fuinorg,项目名称:units4j,代码行数:28,代码来源:Utils.java
示例16: findOverrideMethods
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
private static List<MethodInfo> findOverrideMethods(final Index index, final ClassInfo clasz,
final MethodInfo methodToFind, final int level) {
final List<MethodInfo> methods = new ArrayList<>();
if (clasz != null) {
// Super classes
if (level > 0) {
addIfFound(index, clasz, methodToFind, methods);
}
// Check interfaces
methods.addAll(findInterfaceMethods(index, clasz, methodToFind));
// Check super class
final DotName superName = clasz.superName();
final ClassInfo superClass = index.getClassByName(superName);
methods.addAll(findOverrideMethods(index, superClass, methodToFind, (level + 1)));
}
return methods;
}
开发者ID:fuinorg,项目名称:units4j,代码行数:24,代码来源:Utils.java
示例17: testFindBaseClass
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
@Test
public void testFindBaseClass() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyBaseClass1",
Type.create(DotName.createSimple(Integer.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyBaseClass1");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyBaseClass1.class.getName());
}
开发者ID:fuinorg,项目名称:units4j,代码行数:19,代码来源:UtilsTest.java
示例18: testFindInterface1
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
@Test
public void testFindInterface1() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyInterface1",
Type.create(DotName.createSimple(Long.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyInterface1");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyInterface1.class.getName());
}
开发者ID:fuinorg,项目名称:units4j,代码行数:19,代码来源:UtilsTest.java
示例19: testFindInterface2
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
@Test
public void testFindInterface2() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyInterface2",
Type.create(DotName.createSimple(Boolean.class.getName()), Kind.CLASS));
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyInterface2");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MyInterface2.class.getName());
}
开发者ID:fuinorg,项目名称:units4j,代码行数:19,代码来源:UtilsTest.java
示例20: testFindInterface3
import org.jboss.jandex.MethodInfo; //导入依赖的package包/类
@Test
public void testFindInterface3() {
// PREPARE
final ClassInfo implClass = index.getClassByName(DotName.createSimple(MyClass.class.getName()));
final MethodInfo implMethod = implClass.method("methodMyInterface3");
// TEST
final List<MethodInfo> intfMethods = Utils.findOverrideMethods(index, implMethod);
// VERIFY
assertThat(intfMethods).hasSize(1);
assertThat(intfMethods.get(0).name()).isEqualTo("methodMyInterface3");
assertThat(intfMethods.get(0).declaringClass().name().toString()).isEqualTo(
MySuperInterface.class.getName());
}
开发者ID:fuinorg,项目名称:units4j,代码行数:18,代码来源:UtilsTest.java
注:本文中的org.jboss.jandex.MethodInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论