本文整理汇总了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());
}
示例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;
}
示例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;
}
}