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


Java TypeKind.WILDCARD属性代码示例

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


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

示例1: getCompatibilityType

private CompatibilityType getCompatibilityType(Element field) {
    TypeMirror typeMirror = field.asType();
    for (CompatibilityType compatibilityType : CompatibilityType.values()) {
        if (compatibilityType.mGenericClass == null) {
            if (isAssignable(typeMirror, compatibilityType.mClass)) {
                return compatibilityType;
            }

        } else if (typeMirror.getKind() != TypeKind.WILDCARD) {
            if (isAssignable(mTypeUtils.erasure(typeMirror), compatibilityType.mClass)) {
                List<? extends TypeMirror> typeArguments = ((DeclaredType) typeMirror).getTypeArguments();
                if (typeArguments != null && typeArguments.size() >= 1 && isAssignable(typeArguments.get(0), compatibilityType.mGenericClass)) {
                    return compatibilityType;
                }
            }
        }
    }
    return null;
}
 
开发者ID:evernote,项目名称:android-state,代码行数:19,代码来源:StateProcessor.java

示例2: resolveCapturedType

private static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
    if (tm == null) {
        return tm;
    }
    if (tm.getKind() == TypeKind.ERROR) {
        tm = info.getTrees().getOriginalType((ErrorType) tm);
    }
    TypeMirror type = resolveCapturedTypeInt(info, tm);
    if (type == null) {
        return tm;
    }
    if (type.getKind() == TypeKind.WILDCARD) {
        TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
        if (tmirr != null)
            return tmirr;
        else { //no extends, just '?'
            TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
            return te == null ? null : te.asType();
        }
            
    }
    
    return type;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:TypeUtilities.java

示例3: visitWildcard

@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    int len = DEFAULT_VALUE.length();
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else if (len == 0) {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:TypeUtilities.java

示例4: resolveCapturedType

/**
 * Resolves all captured type variables to their respective wildcards in the given type.
 * @param info CompilationInfo over which the method should work
 * @param tm type to resolve
 * @return resolved type
 * 
 * @since 0.136
 */
public static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
    TypeMirror type = resolveCapturedTypeInt(info, tm);
    
    if (type.getKind() == TypeKind.WILDCARD) {
        TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
        tmirr = tmirr != null ? tmirr : ((WildcardType) type).getSuperBound();
        if (tmirr != null) {
            return tmirr;
        } else { //no extends, just '?
            TypeElement tel = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
            return tel == null ? null : tel.asType();
        }
            
    }
    
    return type;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SourceUtils.java

示例5: visitWildcard

@Override
public StringBuilder visitWildcard(WildcardType t, Boolean p) {
    DEFAULT_VALUE.append("?"); //NOI18N
    TypeMirror bound = t.getSuperBound();
    if (bound == null) {
        bound = t.getExtendsBound();
        if (bound != null) {
            DEFAULT_VALUE.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound, p);
        } else {
            bound = SourceUtils.getBound(t);
            if (bound != null && (bound.getKind() != TypeKind.DECLARED || !((TypeElement)((DeclaredType)bound).asElement()).getQualifiedName().contentEquals("java.lang.Object"))) { //NOI18N
                DEFAULT_VALUE.append(" extends "); //NOI18N
                visit(bound, p);
            }
        }
    } else {
        DEFAULT_VALUE.append(" super "); //NOI18N
        visit(bound, p);
    }
    return DEFAULT_VALUE;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SpringXMLConfigCompletionItem.java

示例6: addDependency

private void addDependency(TypeMirror tm) {
    if (tm.getKind() == TypeKind.ARRAY) {
        addDependency(((ArrayType)tm).getComponentType());
    } else if (tm.getKind() == TypeKind.WILDCARD) {
        WildcardType wt = (WildcardType)tm;
        TypeMirror bound = wt.getSuperBound();
        if (bound == null) {
            bound = wt.getExtendsBound();
        }
        addDependency(bound);
    } else if (tm.getKind() == TypeKind.DECLARED) {
        addDependency(
            ((TypeElement)compilationInfo.getTypes().asElement(tm)).getQualifiedName().toString()
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BeanModelBuilder.java

示例7: unboxBoxed

/**
 * Unbox a wrapper type into a TypeKind. Some additional types are mapped to TypeKinds which cannot really appear in 
 * expressions (at least I hope)
 * 
 * @param tm
 * @return 
 */
private static TypeKind unboxBoxed(TypeMirror tm) {
    TypeElement te = (TypeElement)((DeclaredType)tm).asElement();
    String qn = te.getQualifiedName().toString();
    if (!qn.startsWith("java.lang.")) { // NO18N
        if (qn.equals("java.math.BigInteger")) { // NOI18N
            return TypeKind.WILDCARD;
        }
        return null;
    }
    switch (qn.substring(10)) {
        case "Short": return TypeKind.SHORT; // NOI18N
        case "Long": return TypeKind.LONG; // NOI18N
        case "Byte": return TypeKind.BYTE; // NOI18N
        case "Integer": return TypeKind.INT; // NOI18N
        case "Double": return TypeKind.DOUBLE; // NOI18N
        case "Float": return TypeKind.FLOAT; // NOI18N
        case "Character": return TypeKind.CHAR; // NOI18N
        case "String": return TypeKind.OTHER; // NOI18N
        case "Object": return TypeKind.PACKAGE; // NOI18N
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:MalformedFormatString.java

示例8: resolveCapturedType

public static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
    if (tm == null) {
        return tm;
    }
    if (tm.getKind() == TypeKind.ERROR) {
        tm = info.getTrees().getOriginalType((ErrorType) tm);
    }
    TypeMirror type = resolveCapturedTypeInt(info, tm);
    if (type == null) {
        return tm;
    }
    if (type.getKind() == TypeKind.WILDCARD) {
        TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
        if (tmirr != null)
            return tmirr;
        else { //no extends, just '?'
            TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
            return te == null ? null : te.asType();
        }
            
    }
    
    return type;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:Utilities.java

示例9: decapture

private TypeMirror decapture(TypeMirror argm) {
    if (argm instanceof CapturedType) {
        argm = ((CapturedType)argm).wildcard;
    }
    if (argm.getKind() == TypeKind.WILDCARD) {
        WildcardType wctype = (WildcardType)argm;
        TypeMirror bound = wctype.getExtendsBound();
        if (bound != null) {
            return bound;
        } 
        bound = wctype.getSuperBound();
        if (bound != null) {
            return bound;
        }
        return null;
    } 
    return argm;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ExpectedTypeResolver.java

示例10: visitWildcard

@Override
public Void visitWildcard(WildcardType type, Void p) {
    builder.append("?"); //NOI18N
    TypeMirror bound = type.getSuperBound();
    if (bound == null) {
        bound = type.getExtendsBound();
        if (bound != null) {
            builder.append(" extends "); //NOI18N
            if (bound.getKind() == TypeKind.WILDCARD)
                bound = ((WildcardType)bound).getSuperBound();
            visit(bound);
        }
    } else {
        builder.append(" super "); //NOI18N
        visit(bound);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AutoImport.java

示例11: uncheckedTypeArgument

private boolean uncheckedTypeArgument(TypeMirror arg) {
  if (arg.getKind() == TypeKind.WILDCARD) {
    WildcardType wildcard = (WildcardType) arg;
    if (wildcard.getExtendsBound() == null || isJavaLangObject(wildcard.getExtendsBound())) {
      // This is <?>, unless there's a super bound, in which case it is <? super Foo> and
      // is erased.
      return (wildcard.getSuperBound() != null);
    }
  }
  return true;
}
 
开发者ID:sopak,项目名称:auto-value-step-builder,代码行数:11,代码来源:TypeSimplifier.java

示例12: checkTypesAssignable

public static boolean checkTypesAssignable(CompilationInfo info, TypeMirror from, TypeMirror to) {
    Context c = ((JavacTaskImpl) info.impl.getJavacTask()).getContext();
    if (from.getKind() == TypeKind.TYPEVAR) {
        Types types = Types.instance(c);
        TypeVar t = types.substBound((TypeVar)from, com.sun.tools.javac.util.List.of((Type)from), com.sun.tools.javac.util.List.of(types.boxedTypeOrType((Type)to)));
        return info.getTypes().isAssignable(t.getUpperBound(), to)
                || info.getTypes().isAssignable(to, t.getUpperBound());
    }
    if (from.getKind() == TypeKind.WILDCARD) {
        from = Types.instance(c).wildUpperBound((Type)from);
    }
    return Check.instance(c).checkType(null, (Type)from, (Type)to).getKind() != TypeKind.ERROR;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:SourceUtils.java

示例13: getTypeMirror

private TypeMirror getTypeMirror(WorkingCopy workingCopy, TypeMirror retType) {
if (retType.getKind() == TypeKind.DECLARED) {
    List<? extends TypeMirror> typeArguments = ((DeclaredType) retType).getTypeArguments();
    for (TypeMirror argument : typeArguments) {
	if (argument.getKind() == TypeKind.WILDCARD) {
	    TypeMirror extendsBound = ((WildcardType) argument).getExtendsBound();
	    TypeMirror superBound = ((WildcardType) argument).getSuperBound();
	    if(extendsBound == null && superBound == null) {
		return workingCopy.getTypes().erasure(retType);
	    }
	    if (extendsBound != null) {
		if (shouldApplyErasure(extendsBound)) {
		    return workingCopy.getTypes().erasure(retType);
		}
	    }
	    if (superBound != null) {
		if (shouldApplyErasure(superBound)) {
		    return workingCopy.getTypes().erasure(retType);
		}
	    }
	} else if (argument.getKind() == TypeKind.DECLARED) {
	    if (((DeclaredType) argument).asElement().getModifiers().contains(Modifier.PRIVATE)) {
		return workingCopy.getTypes().erasure(retType);
	    }
	} else {
	    return workingCopy.getTypes().erasure(retType);
	}
    }
} else {
    return workingCopy.getTypes().erasure(retType);
}
return retType;
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:AbstractTestGenerator.java

示例14: getEffectTypeVar

private AnnotatedTypeVariable getEffectTypeVar(TypeMirror typeMirror) {
    if (typeMirror == null) {
        return null;
    } else if (typeMirror.getKind() == TypeKind.WILDCARD) {
        return getEffectTypeVar(((WildcardType) typeMirror).getExtendsBound());

    } else if (typeMirror.getKind() == TypeKind.TYPEVAR) {
        TypeVariable typevar = ((TypeVariable) typeMirror);
        AnnotatedTypeMirror atm =
                analysis.getTypeFactory().getAnnotatedType(typevar.asElement());
        return (AnnotatedTypeVariable) atm;
    } else {
        return null;
    }
}
 
开发者ID:PPewt,项目名称:affinechecker,代码行数:15,代码来源:AffinePointerValue.java

示例15: canBeMissingAnnotations

private static boolean canBeMissingAnnotations(TypeMirror typeMirror) {
    if (typeMirror == null) {
        return false;
    }
    if (typeMirror.getKind() == TypeKind.VOID
            || typeMirror.getKind() == TypeKind.NONE
            || typeMirror.getKind() == TypeKind.PACKAGE) {
        return true;
    }
    if (typeMirror.getKind() == TypeKind.WILDCARD) {
        return canBeMissingAnnotations(((WildcardType) typeMirror).getExtendsBound());
    }
    return typeMirror.getKind() == TypeKind.TYPEVAR;
}
 
开发者ID:PPewt,项目名称:affinechecker,代码行数:14,代码来源:AffinePointerValue.java


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