本文整理汇总了Java中javax.lang.model.element.ExecutableElement.getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableElement.getDefaultValue方法的具体用法?Java ExecutableElement.getDefaultValue怎么用?Java ExecutableElement.getDefaultValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.ExecutableElement
的用法示例。
在下文中一共展示了ExecutableElement.getDefaultValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAnnotationValue
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
protected static AnnotationValue findAnnotationValue(AnnotationMirror mirror, String name) {
ExecutableElement valueMethod = null;
for (ExecutableElement method : ElementFilter.methodsIn(mirror.getAnnotationType().asElement().getEnclosedElements())) {
if (method.getSimpleName().toString().equals(name)) {
valueMethod = method;
break;
}
}
if (valueMethod == null) {
return null;
}
AnnotationValue value = mirror.getElementValues().get(valueMethod);
if (value == null) {
value = valueMethod.getDefaultValue();
}
return value;
}
示例2: getAnnotationValue
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private static AnnotationValue getAnnotationValue(AnnotationMirror mirror, String name) {
ExecutableElement valueMethod = null;
for (ExecutableElement method : ElementFilter.methodsIn(mirror.getAnnotationType().asElement().getEnclosedElements())) {
if (method.getSimpleName().toString().equals(name)) {
valueMethod = method;
break;
}
}
if (valueMethod == null) {
return null;
}
AnnotationValue value = mirror.getElementValues().get(valueMethod);
if (value == null) {
value = valueMethod.getDefaultValue();
}
return value;
}
示例3: addDefaultValueInfo
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void addDefaultValueInfo(Element member, Content annotationDocTree) {
if (utils.isAnnotationType(member)) {
ExecutableElement ee = (ExecutableElement)member;
AnnotationValue value = ee.getDefaultValue();
if (value != null) {
Content dt = HtmlTree.DT(contents.default_);
Content dl = HtmlTree.DL(dt);
Content dd = HtmlTree.DD(new StringContent(value.toString()));
dl.addContent(dd);
annotationDocTree.addContent(dl);
}
}
}
示例4: filterAnnotations
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
/**
* Filter the annotation type members and return either the required
* members or the optional members, depending on the value of the
* required parameter.
*
* @param typeElement The annotation type to process.
* @param required
* @return the annotation type members and return either the required
* members or the optional members, depending on the value of the
* required parameter.
*/
private List<Element> filterAnnotations(TypeElement typeElement, boolean required) {
List<Element> members = utils.getAnnotationMethods(typeElement);
List<Element> targetMembers = new ArrayList<>();
for (Element member : members) {
ExecutableElement ee = (ExecutableElement)member;
if ((required && ee.getDefaultValue() == null)
|| ((!required) && ee.getDefaultValue() != null)) {
targetMembers.add(member);
}
}
return targetMembers;
}