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


Java TypeMirror.equals方法代码示例

本文整理汇总了Java中javax.lang.model.type.TypeMirror.equals方法的典型用法代码示例。如果您正苦于以下问题:Java TypeMirror.equals方法的具体用法?Java TypeMirror.equals怎么用?Java TypeMirror.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.lang.model.type.TypeMirror的用法示例。


在下文中一共展示了TypeMirror.equals方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deepSearchTypes

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private boolean deepSearchTypes(DeclaredType currentElement, TypeMirror orig, TypeMirror something, Map<TypeMirror, TypeParameterElement> mappings) {
    Types types = workingCopy.getTypes();
    List<? extends TypeMirror> directSupertypes = types.directSupertypes(currentElement);
    for (TypeMirror superType : directSupertypes) {
        DeclaredType type = (DeclaredType) superType;
        List<? extends TypeMirror> typeArguments = type.getTypeArguments();
        for (int i = 0; i < typeArguments.size(); i++) {
            TypeMirror typeArgument = typeArguments.get(i);
            if (something.equals(typeArgument)) {
                TypeElement asElement = (TypeElement) type.asElement();
                mappings.put(orig, asElement.getTypeParameters().get(i));
                if (types.erasure(targetType.asType()).equals(types.erasure(superType))) {
                    return true;
                }
                if(deepSearchTypes(type, orig, typeArgument, mappings)) {
                    break;
                }
            }
        }
        if (types.erasure(targetType.asType()).equals(types.erasure(superType))) {
            mappings.remove(orig);
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:PullUpTransformer.java

示例2: getSetter

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private static String getSetter(Map<String,ExecutableElement> moduleMethods, String getter, boolean abstractGetter, TypeMirror type) throws ModelException {
       String result = "set" + getter.substring(3);
	if (!moduleMethods.containsKey(result)) {
		if (abstractGetter)
			return result;
		throw new ModelException("missing parameter setter method: " + result + " (" + getter + ")");
	}
	ExecutableElement setterElement = moduleMethods.get(result);
	if (!ModelContext.isPublic(setterElement))
		throw new ModelException("parameter setter should be public: " + result);
	if (ModelContext.isAbstract(setterElement)) {
		if (!abstractGetter)
			throw new ModelException("parameter setter should not be abstract since getter is implemented: " + result + " (" + getter + ")");
	}
	else {
		if (abstractGetter)
			throw new ModelException("parameter setter should be abstract since the getter is abstract: " + result + " (" + getter + ")");
	}
       List<? extends VariableElement> setterParameterTypes = setterElement.getParameters();
       if (setterParameterTypes.size() != 1)
       	throw new ModelException("parameter setter should be a method with one formal parameter: " + result + " (" + getter + ")");
       TypeMirror setterType = setterParameterTypes.get(0).asType();
       if (!type.equals(setterType))
       	throw new ModelException("parameter setter formal parameter should be the same type as the getter return type: " + result + " (" + getter + ")");
       return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:27,代码来源:ParamModel.java

示例3: getTreeForClassHelper

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
 * Get the class helper tree for the given class.
 *
 * @param type the class to print the helper for
 * @return a content tree for class helper
 */
private Content getTreeForClassHelper(TypeMirror type) {
    Content li = new HtmlTree(HtmlTag.LI);
    if (type.equals(typeElement.asType())) {
        Content typeParameters = getTypeParameterLinks(
                new LinkInfoImpl(configuration, LinkInfoImpl.Kind.TREE,
                typeElement));
        if (configuration.shouldExcludeQualifier(utils.containingPackage(typeElement).toString())) {
            li.addContent(utils.asTypeElement(type).getSimpleName());
            li.addContent(typeParameters);
        } else {
            li.addContent(utils.asTypeElement(type).getQualifiedName());
            li.addContent(typeParameters);
        }
    } else {
        Content link = getLink(new LinkInfoImpl(configuration,
                LinkInfoImpl.Kind.CLASS_TREE_PARENT, type)
                .label(configuration.getClassName(utils.asTypeElement(type))));
        li.addContent(link);
    }
    return li;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ClassWriterImpl.java

示例4: getStatementForAppendingValueToOsList

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private String getStatementForAppendingValueToOsList(
        @SuppressWarnings("SameParameterValue") String osListVariableName,
        @SuppressWarnings("SameParameterValue") String valueVariableName,
        TypeMirror elementTypeMirror) {
    if (elementTypeMirror == typeMirrors.STRING_MIRROR) {
        return osListVariableName + ".addString(" + valueVariableName + ")";
    }
    if (elementTypeMirror == typeMirrors.LONG_MIRROR || elementTypeMirror == typeMirrors.INTEGER_MIRROR
            || elementTypeMirror == typeMirrors.SHORT_MIRROR || elementTypeMirror == typeMirrors.BYTE_MIRROR) {
        return osListVariableName + ".addLong(" + valueVariableName + ".longValue())";
    }
    if (elementTypeMirror.equals(typeMirrors.BINARY_MIRROR)) {
        return osListVariableName + ".addBinary(" + valueVariableName + ")";
    }
    if (elementTypeMirror == typeMirrors.DATE_MIRROR) {
        return osListVariableName + ".addDate(" + valueVariableName + ")";
    }
    if (elementTypeMirror == typeMirrors.BOOLEAN_MIRROR) {
        return osListVariableName + ".addBoolean(" + valueVariableName + ")";
    }
    if (elementTypeMirror == typeMirrors.DOUBLE_MIRROR) {
        return osListVariableName + ".addDouble(" + valueVariableName + ".doubleValue())";
    }
    if (elementTypeMirror == typeMirrors.FLOAT_MIRROR) {
        return osListVariableName + ".addFloat(" + valueVariableName + ".floatValue())";
    }
    throw new RuntimeException("unexpected element type: " + elementTypeMirror.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:RealmProxyClassGenerator.java

示例5: testParentOf

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
/**
 * Test if typeElement is a parent of currentElement.
 */
private static boolean testParentOf(Types types, TypeMirror currentElement, TypeMirror typeMirror) {
    List<? extends TypeMirror> directSupertypes = types.directSupertypes(currentElement);
    for (TypeMirror superType : directSupertypes) {
        if (superType.equals(typeMirror)) {
            return true;
        } else {
            boolean isParent = testParentOf(types, superType, typeMirror);
            if (isParent) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ToolTipAnnotation.java

示例6: resolveFields

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
private void resolveFields(Parameters p) {
    
    // Analyze fields
    List<VariableElement> fields = ElementFilter.fieldsIn(p.element.getEnclosedElements());
    
    String propertyStyle = "this."; //NOI18N
    
    for ( VariableElement field : fields ) {
        
        if ( field.getModifiers().contains(STATIC)) {
            continue;
        }
        
        //System.out.println("Property style " + propertyStyle);   
        String fieldName = nameAsString(field);
        //System.out.println("Field name1 " + fieldName);
        if( fieldName.startsWith(propertyStyle) ){
            fieldName = fieldName.substring(1);
            //System.out.println("Field name2 " + fieldName);
        }
        
        Property pp = p.propertyPatterns.get( fieldName );
        if ( pp == null )
            pp = p.idxPropertyPatterns.get( fieldName );
        if ( pp == null )
            continue;
        TypeMirror ppType = pp.type;
        if ( ppType != null && ppType.equals( field.asType() ) )
            pp.estimatedField = field;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:PatternAnalyser.java

示例7: isArrayButNotByteArray

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
public boolean isArrayButNotByteArray(TypeMirror t) {
    if(!isArray(t))
        return false;

    ArrayType at = (ArrayType) t;
    TypeMirror ct = at.getComponentType();

    return !ct.equals(primitiveByte);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:ApNavigator.java

示例8: run

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
public List<ErrorDescription> run(CompilationInfo compilationInfo, TreePath treePath) {
    Element e = compilationInfo.getTrees().getElement(treePath);
    
    if (   e == null
        || e.getKind() != ElementKind.METHOD
        || !"cancel".equals(e.getSimpleName().toString()) //NOI18N
        || e.getModifiers().contains(Modifier.ABSTRACT)) {
        return null;
    }
    
    Element clazz = e.getEnclosingElement();
    
    if (!clazz.getKind().isClass()) {
        return null;
    }
    
    boolean found = false;
    
    OUT: for (String toCheck : typesToCheck) {
        TypeElement clazzTE = (TypeElement) clazz;
        TypeMirror  clazzTM = clazzTE.asType();
        TypeMirror  typeToCheck = compilationInfo.getTreeUtilities().parseType(toCheck, clazzTE);
        
        if (typeToCheck.getKind() != TypeKind.DECLARED)
            continue;
        
        TypeElement typeToCheckTE = (TypeElement) ((DeclaredType) typeToCheck).asElement();
        
        if (   compilationInfo.getTypes().isSubtype(clazzTM, typeToCheck)
            && !clazzTM.equals(typeToCheck)) {
            for (ExecutableElement ee : ElementFilter.methodsIn(typeToCheckTE.getEnclosedElements())) {
                if (compilationInfo.getElements().overrides((ExecutableElement) e, ee, clazzTE)) {
                    found = true;
                    break OUT;
                }
            }
        }
    }
    
    if (!found) {
        return null;
    }
    
    MethodTree mt = (MethodTree) treePath.getLeaf();
    
    if (mt.getBody() == null || !mt.getBody().getStatements().isEmpty()) {
        return null;
    }
    
    int[] span = compilationInfo.getTreeUtilities().findNameSpan((MethodTree) treePath.getLeaf());

    if (span != null) {
        String message = NbBundle.getMessage(EmptyCancelForCancellableTask.class, "MSG_EmptyCancel");
        ErrorDescription ed = ErrorDescriptionFactory.createErrorDescription(getSeverity().toEditorSeverity(), message, compilationInfo.getFileObject(), span[0], span[1]);

        return Collections.singletonList(ed);
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:61,代码来源:EmptyCancelForCancellableTask.java

示例9: constantArgument

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
protected static void constantArgument(ProcessingEnvironment env, PrintWriter out, InjectedDependencies deps, int argIdx, TypeMirror type, int nodeIdx) {
    if (hasRawtypeWarning(type)) {
        out.printf("            @SuppressWarnings({\"rawtypes\"})\n");
    }
    out.printf("            %s arg%d;\n", getErasedType(type), argIdx);
    out.printf("            if (args[%d].isConstant()) {\n", nodeIdx);
    if (type.equals(resolvedJavaTypeType(env))) {
        out.printf("                arg%d = %s.asJavaType(args[%d].asConstant());\n", argIdx, deps.use(WellKnownDependency.CONSTANT_REFLECTION), nodeIdx);
    } else {
        switch (type.getKind()) {
            case BOOLEAN:
                out.printf("                arg%d = args[%d].asJavaConstant().asInt() != 0;\n", argIdx, nodeIdx);
                break;
            case BYTE:
                out.printf("                arg%d = (byte) args[%d].asJavaConstant().asInt();\n", argIdx, nodeIdx);
                break;
            case CHAR:
                out.printf("                arg%d = (char) args[%d].asJavaConstant().asInt();\n", argIdx, nodeIdx);
                break;
            case SHORT:
                out.printf("                arg%d = (short) args[%d].asJavaConstant().asInt();\n", argIdx, nodeIdx);
                break;
            case INT:
                out.printf("                arg%d = args[%d].asJavaConstant().asInt();\n", argIdx, nodeIdx);
                break;
            case LONG:
                out.printf("                arg%d = args[%d].asJavaConstant().asLong();\n", argIdx, nodeIdx);
                break;
            case FLOAT:
                out.printf("                arg%d = args[%d].asJavaConstant().asFloat();\n", argIdx, nodeIdx);
                break;
            case DOUBLE:
                out.printf("                arg%d = args[%d].asJavaConstant().asDouble();\n", argIdx, nodeIdx);
                break;
            case ARRAY:
            case DECLARED:
                out.printf("                arg%d = %s.asObject(%s.class, args[%d].asJavaConstant());\n", argIdx, deps.use(WellKnownDependency.SNIPPET_REFLECTION), getErasedType(type), nodeIdx);
                break;
            default:
                throw new IllegalArgumentException(type.toString());
        }
    }
    out.printf("            } else {\n");
    out.printf("                return false;\n");
    out.printf("            }\n");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:GeneratedPlugin.java

示例10: ignoreBounds

import javax.lang.model.type.TypeMirror; //导入方法依赖的package包/类
public boolean ignoreBounds(TypeMirror bound) {
    return bound.equals(getObjectType()) && !isAnnotated(bound);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:Utils.java


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