本文整理汇总了Java中javax.lang.model.element.ExecutableElement.isDefault方法的典型用法代码示例。如果您正苦于以下问题:Java ExecutableElement.isDefault方法的具体用法?Java ExecutableElement.isDefault怎么用?Java ExecutableElement.isDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.lang.model.element.ExecutableElement
的用法示例。
在下文中一共展示了ExecutableElement.isDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isElementSuitableMethod
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
static boolean isElementSuitableMethod(Element enclosedElement) {
if (enclosedElement.getKind() == ElementKind.METHOD) {
ExecutableElement method = (ExecutableElement) enclosedElement;
if (method.isDefault()) {
return false;
}
if (method.getModifiers().contains(Modifier.STATIC)) {
return false;
}
}
return true;
}
示例2: createBindings
import javax.lang.model.element.ExecutableElement; //导入方法依赖的package包/类
private Map<String, Object> createBindings(TypeElement clazz, ExecutableElement element) {
CodeStyle cs = DiffContext.getCodeStyle(copy);
Map<String, Object> bindings = new HashMap<>();
if (clazz != null) {
bindings.put(CLASS_NAME, clazz.getQualifiedName().toString());
bindings.put(SIMPLE_CLASS_NAME, clazz.getSimpleName().toString());
}
if (element != null) {
bindings.put(METHOD_NAME, element.getSimpleName().toString());
bindings.put(METHOD_RETURN_TYPE, element.getReturnType().toString()); //NOI18N
Object value;
switch(element.getReturnType().getKind()) {
case BOOLEAN:
value = "false"; //NOI18N
break;
case BYTE:
case CHAR:
case DOUBLE:
case FLOAT:
case INT:
case LONG:
case SHORT:
value = 0;
break;
default:
value = "null"; //NOI18N
}
bindings.put(DEFAULT_RETURN_TYPE_VALUE, value);
}
if (clazz != null && element != null) {
StringBuilder sb = new StringBuilder();
if (element.isDefault() && element.getEnclosingElement().getKind().isInterface()) {
Types types = copy.getTypes();
Context ctx = ((JavacTaskImpl) copy.impl.getJavacTask()).getContext();
com.sun.tools.javac.code.Types typesImpl = com.sun.tools.javac.code.Types.instance(ctx);
TypeMirror enclType = typesImpl.asSuper((Type)clazz.asType(), ((Type)element.getEnclosingElement().asType()).tsym);
if (!types.isSubtype(clazz.getSuperclass(), enclType)) {
TypeMirror selected = enclType;
for (TypeMirror iface : clazz.getInterfaces()) {
if (types.isSubtype(iface, selected) &&
!types.isSameType(iface, enclType)) {
selected = iface;
break;
}
}
sb.append(((DeclaredType)selected).asElement().getSimpleName()).append('.');
}
}
sb.append("super.").append(element.getSimpleName()).append('('); //NOI18N
for (Iterator<? extends VariableElement> it = element.getParameters().iterator(); it.hasNext();) {
VariableElement ve = it.next();
sb.append(addParamPrefixSuffix(removeParamPrefixSuffix(ve, cs), cs));
if (it.hasNext())
sb.append(","); //NOI18N
}
sb.append(')'); //NOI18N
bindings.put(SUPER_METHOD_CALL, sb);
}
return bindings;
}