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


Java MethodSource.isPublic方法代码示例

本文整理汇总了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;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:17,代码来源:CamelJavaParserHelper.java

示例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;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:21,代码来源:CamelJavaParserHelper.java

示例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;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:8,代码来源:CamelJavaParserHelper.java

示例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;
    }
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:55,代码来源:JavaRoasterModelDriver.java


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