本文整理匯總了Java中javax.lang.model.type.WildcardType類的典型用法代碼示例。如果您正苦於以下問題:Java WildcardType類的具體用法?Java WildcardType怎麽用?Java WildcardType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
WildcardType類屬於javax.lang.model.type包,在下文中一共展示了WildcardType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: visitWildcard
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
@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 = 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;
}
示例2: visitWildcard
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
@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;
}
示例3: resolveCapturedType
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
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;
}
示例4: visitWildcard
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
@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;
}
示例5: resolveCapturedType
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
/**
* 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;
}
示例6: visitWildcard
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
@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;
}
示例7: addDependency
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
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()
);
}
}
示例8: resolveCapturedType
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
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;
}
示例9: containedTypevarsRecursively
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
private static void containedTypevarsRecursively(@NonNull TypeMirror tm, @NonNull Collection<TypeVariable> typeVars) {
switch (tm.getKind()) {
case TYPEVAR:
typeVars.add((TypeVariable) tm);
break;
case DECLARED:
DeclaredType type = (DeclaredType) tm;
for (TypeMirror t : type.getTypeArguments()) {
containedTypevarsRecursively(t, typeVars);
}
break;
case ARRAY:
containedTypevarsRecursively(((ArrayType) tm).getComponentType(), typeVars);
break;
case WILDCARD:
if (((WildcardType) tm).getExtendsBound() != null) {
containedTypevarsRecursively(((WildcardType) tm).getExtendsBound(), typeVars);
}
if (((WildcardType) tm).getSuperBound() != null) {
containedTypevarsRecursively(((WildcardType) tm).getSuperBound(), typeVars);
}
break;
}
}
示例10: decapture
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
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;
}
示例11: visitWildcard
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
@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;
}
示例12: getErasedType
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
static String getErasedType(TypeMirror type) {
switch (type.getKind()) {
case DECLARED:
DeclaredType declared = (DeclaredType) type;
TypeElement element = (TypeElement) declared.asElement();
return element.getQualifiedName().toString();
case TYPEVAR:
return getErasedType(((TypeVariable) type).getUpperBound());
case WILDCARD:
return getErasedType(((WildcardType) type).getExtendsBound());
case ARRAY:
return getErasedType(((ArrayType) type).getComponentType()) + "[]";
default:
return type.toString();
}
}
示例13: hasUncheckedWarning
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
static boolean hasUncheckedWarning(TypeMirror type) {
switch (type.getKind()) {
case DECLARED:
DeclaredType declared = (DeclaredType) type;
for (TypeMirror typeParam : declared.getTypeArguments()) {
if (hasUncheckedWarning(typeParam)) {
return true;
}
}
return false;
case TYPEVAR:
return true;
case WILDCARD:
return ((WildcardType) type).getExtendsBound() != null;
case ARRAY:
return hasUncheckedWarning(((ArrayType) type).getComponentType());
default:
return false;
}
}
示例14: appendSimpleTypeName
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
private static void appendSimpleTypeName(StringBuilder ret, TypeMirror type) {
switch (type.getKind()) {
case DECLARED:
DeclaredType declared = (DeclaredType) type;
TypeElement element = (TypeElement) declared.asElement();
ret.append(element.getSimpleName());
break;
case TYPEVAR:
appendSimpleTypeName(ret, ((TypeVariable) type).getUpperBound());
break;
case WILDCARD:
appendSimpleTypeName(ret, ((WildcardType) type).getExtendsBound());
break;
case ARRAY:
appendSimpleTypeName(ret, ((ArrayType) type).getComponentType());
ret.append("Array");
break;
default:
ret.append(type);
}
}
示例15: AnnotationInfo
import javax.lang.model.type.WildcardType; //導入依賴的package包/類
public AnnotationInfo(TypeMirror tm, String idProperty, boolean keepNonIdProperty,
TypeMirror idGeneratorType, boolean customGenerator) {
this.tm = tm;
if (tm.getKind() != TypeKind.DECLARED) {
throw new RuntimeException(tm + " should be declared");
}
DeclaredType dt = (DeclaredType) tm;
List<? extends TypeMirror> typeArguments = dt.getTypeArguments();
if (typeArguments != null) {
for (TypeMirror tms : typeArguments) {
if (tms instanceof TypeVariable) {
typeVariables.add((TypeVariable) tms);
} else if (tms instanceof WildcardType) {
typeWildcards.add((WildcardType) tms);
}
}
}
this.idGeneratorType = idGeneratorType;
this.customGenerator = customGenerator;
this.idProperty = Strings.nullToEmpty(idProperty).trim();
this.keepNonIdProperty = keepNonIdProperty;
}