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


Java JavaMethod.getTagByName方法代码示例

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


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

示例1: processRestMethod

import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private void processRestMethod(JavaMethod javaMethod, String method,
                               Map<String, ObjectNode> pathMap,
                               String resourcePath, ArrayNode tagArray, ObjectNode definitions) {
    String fullPath = resourcePath, consumes = "", produces = "",
            comment = javaMethod.getComment();
    DocletTag tag = javaMethod.getTagByName("onos.rsModel");
    for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
        String name = annotation.getType().getName();
        if (name.equals(PATH)) {
            fullPath = resourcePath + "/" + getPath(annotation);
            fullPath = fullPath.replaceFirst("^//", "/");
        }
        if (name.equals(CONSUMES)) {
            consumes = getIOType(annotation);
        }
        if (name.equals(PRODUCES)) {
            produces = getIOType(annotation);
        }
    }
    ObjectNode methodNode = mapper.createObjectNode();
    methodNode.set("tags", tagArray);

    addSummaryDescriptions(methodNode, comment);
    addJsonSchemaDefinition(definitions, tag);

    processParameters(javaMethod, methodNode, method, tag);

    processConsumesProduces(methodNode, "consumes", consumes);
    processConsumesProduces(methodNode, "produces", produces);
    if (tag == null || ((method.toLowerCase().equals("post") || method.toLowerCase().equals("put"))
            && !(tag.getParameters().size() > 1))) {
        addResponses(methodNode, tag, false);
    } else {
        addResponses(methodNode, tag, true);
    }

    ObjectNode operations = pathMap.get(fullPath);
    if (operations == null) {
        operations = mapper.createObjectNode();
        operations.set(method, methodNode);
        pathMap.put(fullPath, operations);
    } else {
        operations.set(method, methodNode);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:46,代码来源:OnosSwaggerMojo.java

示例2: processRestMethod

import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private void processRestMethod(JavaMethod javaMethod, String method,
                               Map<String, ObjectNode> pathMap,
                               String resourcePath, ArrayNode tagArray,
                               ObjectNode definitions, File srcDirectory) {
    String fullPath = resourcePath, consumes = "", produces = "",
            comment = javaMethod.getComment();
    DocletTag tag = javaMethod.getTagByName("onos.rsModel");
    for (JavaAnnotation annotation : javaMethod.getAnnotations()) {
        String name = annotation.getType().getName();
        if (name.equals(PATH)) {
            fullPath = resourcePath + "/" + getPath(annotation);
            fullPath = fullPath.replaceFirst("^//", "/");
        }
        if (name.equals(CONSUMES)) {
            consumes = getIOType(annotation);
        }
        if (name.equals(PRODUCES)) {
            produces = getIOType(annotation);
        }
    }
    ObjectNode methodNode = mapper.createObjectNode();
    methodNode.set("tags", tagArray);

    addSummaryDescriptions(methodNode, comment);
    addJsonSchemaDefinition(srcDirectory, definitions, tag);

    processParameters(javaMethod, methodNode, method, tag);

    processConsumesProduces(methodNode, "consumes", consumes);
    processConsumesProduces(methodNode, "produces", produces);
    if (tag == null || !(tag.getParameters().size() > 1)) {
        addResponses(javaMethod, methodNode, tag, false);
    } else {
        addResponses(javaMethod, methodNode, tag, true);
    }

    ObjectNode operations = pathMap.get(fullPath);
    if (operations == null) {
        operations = mapper.createObjectNode();
        operations.set(method, methodNode);
        pathMap.put(fullPath, operations);
    } else {
        operations.set(method, methodNode);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:46,代码来源:SwaggerGenerator.java

示例3: createMethodModel

import com.thoughtworks.qdox.model.JavaMethod; //导入方法依赖的package包/类
private EventMethodModel createMethodModel(JavaMethod method)
        throws EventConventionException, ClassNotFoundException {
    JavaClass clazz = method.getParentClass();
    //Check EventProducer conventions
    if (!method.getReturnType().isVoid()) {
        throw new EventConventionException("All methods of interface "
                + clazz.getFullyQualifiedName() + " must have return type 'void'!");
    }
    String methodSig = clazz.getFullyQualifiedName() + "." + method.getCallSignature();
    JavaParameter[] params = method.getParameters();
    if (params.length < 1) {
        throw new EventConventionException("The method " + methodSig
                + " must have at least one parameter: 'Object source'!");
    }
    Type firstType = params[0].getType();
    if (firstType.isPrimitive() || !"source".equals(params[0].getName())) {
        throw new EventConventionException("The first parameter of the method " + methodSig
                + " must be: 'Object source'!");
    }

    //build method model
    DocletTag tag = method.getTagByName("event.severity");
    EventSeverity severity;
    if (tag != null) {
        severity = EventSeverity.valueOf(tag.getValue());
    } else {
        severity = EventSeverity.INFO;
    }
    EventMethodModel methodMeta = new EventMethodModel(
            method.getName(), severity);
    if (params.length > 1) {
        for (int j = 1, cj = params.length; j < cj; j++) {
            JavaParameter p = params[j];
            Class<?> type;
            JavaClass pClass = p.getType().getJavaClass();
            if (p.getType().isPrimitive()) {
                type = PRIMITIVE_MAP.get(pClass.getName());
                if (type == null) {
                    throw new UnsupportedOperationException(
                            "Primitive datatype not supported: " + pClass.getName());
                }
            } else {
                String className = pClass.getFullyQualifiedName();
                type = Class.forName(className);
            }
            methodMeta.addParameter(type, p.getName());
        }
    }
    Type[] exceptions = method.getExceptions();
    if (exceptions != null && exceptions.length > 0) {
        //We only use the first declared exception because that is always thrown
        JavaClass cl = exceptions[0].getJavaClass();
        methodMeta.setExceptionClass(cl.getFullyQualifiedName());
        methodMeta.setSeverity(EventSeverity.FATAL); //In case it's not set in the comments
    }
    return methodMeta;
}
 
开发者ID:pellcorp,项目名称:fop,代码行数:58,代码来源:EventProducerCollector.java


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