All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gitee.l0km.javadocreader.JavadocParameterNames Maven / Gradle / Ivy

There is a newer version: 1.1.0
Show newest version
package com.gitee.l0km.javadocreader;

import java.lang.reflect.Member;

import javax.lang.model.element.TypeElement;

import com.gitee.l0km.com4j.base.BaseParameterNames;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * 基于JavaDoc解析类的源码实现获取构造函数或方法的参数名
* @author guyadong * */ public class JavadocParameterNames extends BaseParameterNames { private final ExtClassDoc extClassDoc; public JavadocParameterNames(Class clazz) { super(clazz); this.extClassDoc = JavadocReader.read(clazz); } public JavadocParameterNames(ExtClassDoc extClassDoc) { super(toClass(extClassDoc)); this.extClassDoc = extClassDoc; } private static Class toClass(TypeElement classDoc){ try { return Class.forName(checkNotNull(classDoc,"classDoc is null").getQualifiedName().toString()); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } private static Class toClass(ExtClassDoc extClassDoc){ return toClass(checkNotNull(extClassDoc,"extClassDoc is null").getClassDoc()); } @Override protected String[] doGetParameterNames(Member member) { if(extClassDoc != null && clazz != null){ TypeElement classDoc = extClassDoc.getClassDoc(); if(classDoc != null){ return extClassDoc.getParamerNames(member); } } return null; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy