当前位置: 首页>>代码示例>>Java>>正文


Java ExecutableElement.isDefault方法代码示例

本文整理汇总了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;
    
}
 
开发者ID:nsforth,项目名称:vxrifa,代码行数:18,代码来源:GeneratorsHelper.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:GeneratorUtilities.java


注:本文中的javax.lang.model.element.ExecutableElement.isDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。