当前位置: 首页>>代码示例>>Java>>正文


Java MethodSource.getAnnotations方法代码示例

本文整理汇总了Java中org.jboss.forge.roaster.model.source.MethodSource.getAnnotations方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSource.getAnnotations方法的具体用法?Java MethodSource.getAnnotations怎么用?Java MethodSource.getAnnotations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.roaster.model.source.MethodSource的用法示例。


在下文中一共展示了MethodSource.getAnnotations方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getEventHandler

import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
private void getEventHandler(final MethodSource<JavaClassSource> method, final String listenerName) {
   final String eventTypeName = method.getParameters()
         .get(0)
         .getType()
         .getName();

   String eventHandlerType = null;

   for (AnnotationSource<JavaClassSource> annotation : method.getAnnotations()) {
      eventHandlerType = axonUtil.getEventHandlerType(annotation.getName());
   }

   if (eventHandlerType == null) {
      throw new VisualAxonException(method.getName() + " is not a valid Axon EventHandler");
   }

   eventBus.post(EventHandlerSpotted.builder()
         .eventName(eventTypeName)
         .type(eventHandlerType)
         .listener(listenerName)
         .build());
}
 
开发者ID:Herumgeisterer,项目名称:visualaxon,代码行数:23,代码来源:AxonSpotter.java

示例2: isCommandHandler

import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
public boolean isCommandHandler(final MethodSource<JavaClassSource> method) {
   final List<AnnotationSource<JavaClassSource>> annotations = method.getAnnotations();

   for (AnnotationSource<JavaClassSource> annotation : annotations) {
      final String annotationName = annotation.getName();
      if (annotationName.equals(COMMAND_HANDLER)) {
         return true;
      }
   }

   return false;
}
 
开发者ID:Herumgeisterer,项目名称:visualaxon,代码行数:13,代码来源:AxonUtil.java

示例3: isGeneratedConstructor

import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
/**
 * @param constructor a Constructor method to check.
 * @return true, if the given constructor was generated by the data modeler.
 */
public boolean isGeneratedConstructor(MethodSource<JavaClassSource> constructor) {
    if (constructor.isAbstract() || constructor.isStatic() || constructor.isFinal()) {
        return false;
    }
    if (!constructor.isPublic()) {
        return false; //we only generate public constructors.
    }

    if (constructor.getAnnotations() != null && constructor.getAnnotations().size() > 0) {
        return false; //we never add annotations to constructors
    }

    List<ParameterSource<JavaClassSource>> parameters = constructor.getParameters();
    List<String> expectedLines = new ArrayList<String>();
    String expectedLine;
    if (parameters != null) {
        for (ParameterSource<JavaClassSource> param : parameters) {
            if (param.getAnnotations() != null && param.getAnnotations().size() > 0) {
                return false; //we never add annotations to parameters
            }
            //ideally we should know if the parameter is final, but Roaster don't provide that info.
            expectedLine = "this." + param.getName() + "=" + param.getName() + ";";
            expectedLines.add(expectedLine);
        }
    }

    String body = constructor.getBody();
    if (body == null || (body = body.trim()).isEmpty()) {
        return false;
    }

    try {
        BufferedReader reader = new BufferedReader(new StringReader(body));
        String line = null;
        int lineNumber = 0;
        while ((line = reader.readLine()) != null) {
            lineNumber++;
            if (lineNumber > expectedLines.size()) {
                return false;
            }
            if (!line.trim().equals(expectedLines.get(lineNumber - 1))) {
                return false;
            }
        }

        return lineNumber == expectedLines.size();
    } catch (IOException e) {
        return false;
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:55,代码来源:JavaRoasterModelDriver.java


注:本文中的org.jboss.forge.roaster.model.source.MethodSource.getAnnotations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。