本文整理匯總了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;
}