com.thoughtworks.qdox.model.JavaField Java Examples

The following examples show how to use com.thoughtworks.qdox.model.JavaField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocUtil.java    From smart-doc with Apache License 2.0 5 votes vote down vote up
/**
 * Get field tags
 *
 * @param field        JavaField
 * @param docJavaField DocJavaField
 * @return map
 */
public static Map<String, String> getFieldTagsValue(final JavaField field, DocJavaField docJavaField) {
    List<DocletTag> paramTags = field.getTags();
    if (CollectionUtil.isEmpty(paramTags) && Objects.nonNull(docJavaField)) {
        paramTags = docJavaField.getDocletTags();
    }
    return paramTags.stream().collect(Collectors.toMap(DocletTag::getName, DocletTag::getValue,
            (key1, key2) -> key1 + "," + key2));
}
 
Example #2
Source File: MockClassInfo.java    From auto-generate-test-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 存储父类的信息
 *  @param javaGenInfoModel 存储的类信息
 * @param javaField 类属性信息
 * @param javaMockClassInfoDTO 模板中的类信息
 * @param superClass 父类
 * @param javaClassModel 类信息
 */
private static void handleSuperClass(JavaGenInfoModel javaGenInfoModel, JavaField javaField, JavaMockClassInfoDTO javaMockClassInfoDTO, JavaClass superClass, JavaClassModel javaClassModel) {
    //父类的方法
    Map<String, JavaClassModel> javaClassModelMap= javaGenInfoModel.getJavaClassModelMap();
    List<JavaMethod> superJavaMethod = superClass.getMethods();
    JavaClassModel superJavaClassModel = new JavaClassModel();
    superJavaClassModel.setName(superClass.getName());
    superJavaClassModel.setType(InitConstant.getAbbreviation(superClass.getFullyQualifiedName()));
    superJavaClassModel.setFullyType(superClass.getFullyQualifiedName());
    List<JavaMethodModel> javaMethodModelList1 = new ArrayList<>();

    for (JavaMethod javaMethod : superJavaMethod) {
        JavaMethodModel javaMethodModel = getJavaMethodModel(javaMethod, javaField.getName(),javaField.getType().getFullyQualifiedName(), superClass);
        String key = javaClassModel.getName() + "." + javaMethodModel.getName();
        Map<String, String> mockFullyTypeNameMap = javaGenInfoModel.getMockFullyTypeNameMap();
        if (!mockFullyTypeNameMap.containsKey(key)) {
            mockFullyTypeNameMap.put(key, superJavaClassModel.getFullyType());
        }
        javaMethodModelList1.add(javaMethodModel);
    }
    superJavaClassModel.setJavaMethodModelList(javaMethodModelList1);
    if (!javaClassModelMap.containsKey(superJavaClassModel.getFullyType())) {
        javaClassModelMap.put(superJavaClassModel.getFullyType(), superJavaClassModel);
    }

    //TODO 暂时只处理一个接口 ,如果是接口,暂时设置最后一个接口的全限定名称 - 后面需要将接口和类进行区分
    javaMockClassInfoDTO.setParentClassFullyType(superClass.getFullyQualifiedName());

}
 
Example #3
Source File: MockClassInfo.java    From auto-generate-test-maven-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 设置mock方法的信息
 *
 * @param javaField 类属性
 * @param javaMethod 方法
 * @param superClass 父类
 */
private static JavaMockMethodInfoDTO setMockMethodInfo(JavaField javaField, JavaMethod javaMethod, JavaClass superClass) {

    JavaMethodModel javaMethodModel = getJavaMethodModel(javaMethod, javaField.getName(),javaField.getType().getFullyQualifiedName(), superClass);

    JavaMockMethodInfoDTO javaMockMethodInfoDTO = new JavaMockMethodInfoDTO();

    javaMockMethodInfoDTO.setParentClassFullyType(javaMethodModel.getParentClassFullyType());
    javaMockMethodInfoDTO.setFieldName(javaMethodModel.getFieldName());
    javaMockMethodInfoDTO.setClassType(javaMethodModel.getClassType());
    javaMockMethodInfoDTO.setName(javaMethodModel.getName());

    List<JavaParameteModel> javaParameteModelList = javaMethodModel.getJavaParameteModelList();
    List<JavaParameterDTO> javaParameterDTOList = new ArrayList<>();
    if (javaParameteModelList != null) {
        for (JavaParameteModel javaParameteModel : javaParameteModelList) {
            JavaParameterDTO javaParameterDTO = new JavaParameterDTO();
            javaParameterDTO.setName(javaParameteModel.getName());
            javaParameterDTO.setUpName(javaParameteModel.getUpName());
            javaParameterDTO.setType(javaParameteModel.getType());
            javaParameterDTO.setFullyType(javaParameteModel.getFullyType());
            javaParameterDTO.setCustomType(javaParameteModel.getCustomType());
            javaParameterDTO.setValue(javaParameteModel.getValue());
            javaParameterDTOList.add(javaParameterDTO);
        }
    }
    javaMockMethodInfoDTO.setJavaParameterDTOList(javaParameterDTOList);
    javaMockMethodInfoDTO.setReturnFullyType(javaMethodModel.getReturnFullyType());
    javaMockMethodInfoDTO.setReturnType(javaMethodModel.getReturnType());

    return javaMockMethodInfoDTO;
}
 
Example #4
Source File: CfgDefGenerator.java    From onos with Apache License 2.0 5 votes vote down vote up
private String description(JavaClass javaClass, String name) {
    if (name.startsWith("_")) {
        // Static property - just leave it as is, not for inclusion in the cfg defs
        return null;
    }
    JavaField field = javaClass.getFieldByName(name);
    if (field != null) {
        String comment = field.getComment();
        return comment != null ? comment : NO_DESCRIPTION;
    }
    throw new IllegalStateException("cfgdef could not find a variable named " + name + " in " + javaClass.getName());
}
 
Example #5
Source File: OnosCfgMojo.java    From onos with Apache License 2.0 5 votes vote down vote up
private String description(JavaClass javaClass, String name) {
    if (name.startsWith("_")) {
        // Static property - just leave it as is, not for inclusion in the cfg defs
        return null;
    }
    JavaField field = javaClass.getFieldByName(name);
    if (field != null) {
        String comment = field.getComment();
        return comment != null ? comment : NO_DESCRIPTION;
    }
    throw new IllegalStateException("cfgdef could not find a variable named " + name + " in " + javaClass.getName());
}
 
Example #6
Source File: DocJavaField.java    From smart-doc with Apache License 2.0 4 votes vote down vote up
public JavaField getJavaField() {
    return javaField;
}
 
Example #7
Source File: DocJavaField.java    From smart-doc with Apache License 2.0 4 votes vote down vote up
public DocJavaField setJavaField(JavaField javaField) {
    this.javaField = javaField;
    return this;
}