本文整理汇总了Java中org.jboss.forge.roaster.model.source.MethodSource.isPublic方法的典型用法代码示例。如果您正苦于以下问题:Java MethodSource.isPublic方法的具体用法?Java MethodSource.isPublic怎么用?Java MethodSource.isPublic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.forge.roaster.model.source.MethodSource
的用法示例。
在下文中一共展示了MethodSource.isPublic方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findConfigureMethod
import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
public static MethodSource<JavaClassSource> findConfigureMethod(JavaClassSource clazz) {
MethodSource<JavaClassSource> method = clazz.getMethod("configure");
// must be public void configure()
if (method != null && method.isPublic() && method.getParameters().isEmpty() && method.getReturnType().isType("void")) {
return method;
}
// maybe the route builder is from unit testing with camel-test as an anonymous inner class
// there is a bit of code to dig out this using the eclipse jdt api
method = findCreateRouteBuilderMethod(clazz);
if (method != null) {
return findConfigureMethodInCreateRouteBuilder(clazz, method);
}
return null;
}
示例2: findInlinedConfigureMethods
import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
public static List<MethodSource<JavaClassSource>> findInlinedConfigureMethods(JavaClassSource clazz) {
List<MethodSource<JavaClassSource>> answer = new ArrayList<>();
List<MethodSource<JavaClassSource>> methods = clazz.getMethods();
if (methods != null) {
for (MethodSource<JavaClassSource> method : methods) {
if (method.isPublic()
&& (method.getParameters() == null || method.getParameters().isEmpty())
&& (method.getReturnType() == null || method.getReturnType().isType("void"))) {
// maybe the method contains an inlined createRouteBuilder usually from an unit test method
MethodSource<JavaClassSource> builder = findConfigureMethodInCreateRouteBuilder(clazz, method);
if (builder != null) {
answer.add(builder);
}
}
}
}
return answer;
}
示例3: findCreateRouteBuilderMethod
import org.jboss.forge.roaster.model.source.MethodSource; //导入方法依赖的package包/类
private static MethodSource<JavaClassSource> findCreateRouteBuilderMethod(JavaClassSource clazz) {
MethodSource method = clazz.getMethod("createRouteBuilder");
if (method != null && (method.isPublic() || method.isProtected()) && method.getParameters().isEmpty()) {
return method;
}
return null;
}
示例4: 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;
}
}