本文整理汇总了Java中com.github.javaparser.ast.type.WildcardType类的典型用法代码示例。如果您正苦于以下问题:Java WildcardType类的具体用法?Java WildcardType怎么用?Java WildcardType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WildcardType类属于com.github.javaparser.ast.type包,在下文中一共展示了WildcardType类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public void visit(final WildcardType n, final Object arg) {
printer.printLn("WildcardType");
printJavaComment(n.getComment(), arg);
if (n.getAnnotations() != null) {
for (AnnotationExpr ae : n.getAnnotations()) {
printer.print(" ");
ae.accept(this, arg);
}
}
printer.print("?");
if (n.getExtends() != null) {
printer.print(" extends ");
n.getExtends().accept(this, arg);
}
if (n.getSuper() != null) {
printer.print(" super ");
n.getSuper().accept(this, arg);
}
}
示例2: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public JCTree visit(final WildcardType n, final Object arg) {
//ARG0: TypeBoundKind kind
// For < ? extends> or < ? super > or < ? >
TypeBoundKind arg0;
//ARG1: JCTree inner
// A class associated to this type, if any
JCTree arg1;
if (n.getExtends() != null) {
arg0 = new ATypeBoundKind(make.TypeBoundKind(EXTENDS), null);
arg1 = n.getExtends().accept(this, arg);
} else if (n.getSuper() != null) {
arg0 = new ATypeBoundKind(make.TypeBoundKind(SUPER), null);
arg1 = n.getSuper().accept(this, arg);
} else {
arg0 = new ATypeBoundKind(make.TypeBoundKind(UNBOUND), null);
arg1 = null;
}
return new AJCWildcard(make.Wildcard(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例3: apply
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
public TypeRef apply(Type type) {
if (type instanceof VoidType) {
return new VoidRef();
} else if (type instanceof WildcardType) {
return new WildcardRef();
} else if (type instanceof ReferenceType) {
ReferenceType referenceType = (ReferenceType) type;
int dimensions = referenceType.getArrayCount();
TypeRef typeRef = TYPEREF.apply(referenceType.getType());
if (dimensions == 0) {
return typeRef;
} else if (typeRef instanceof ClassRef) {
return new ClassRefBuilder((ClassRef)typeRef).withDimensions(dimensions).build();
} else if (typeRef instanceof PrimitiveRef) {
return new PrimitiveRefBuilder((PrimitiveRef)typeRef).withDimensions(dimensions).build();
} else if (typeRef instanceof TypeParamRef) {
return new TypeParamRefBuilder((TypeParamRef)typeRef).withDimensions(dimensions).build();
}
} else if (type instanceof PrimitiveType) {
PrimitiveType primitiveType = (PrimitiveType) type;
return new PrimitiveRefBuilder().withName(primitiveType.getType().name()).build();
} else if (type instanceof ClassOrInterfaceType) {
return CLASS_OR_TYPEPARAM_REF.apply((ClassOrInterfaceType) type);
}
throw new IllegalArgumentException("Can't handle type:[" + type + "].");
}
示例4: doMerge
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public WildcardType doMerge(WildcardType first, WildcardType second) {
WildcardType wt = new WildcardType();
wt.setAnnotations(mergeCollections(first.getAnnotations(),second.getAnnotations()));
wt.setExtends(mergeSingle(first.getExtends(),second.getExtends()));
wt.setSuper(mergeSingle(first.getSuper(),second.getSuper()));
return first;
}
示例5: asKind
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
public static TypeKind asKind(Type type) {
if(type instanceof ClassOrInterfaceType) {
return TypeKind.DECLARED;
} else if(type instanceof PrimitiveType) {
switch (((PrimitiveType) type).getType()) {
case Boolean:
return TypeKind.BOOLEAN;
case Byte:
return TypeKind.BYTE;
case Char:
return TypeKind.CHAR;
case Double:
return TypeKind.DOUBLE;
case Float:
return TypeKind.FLOAT;
case Int:
return TypeKind.INT;
case Long:
return TypeKind.LONG;
case Short:
return TypeKind.SHORT;
}
} else if(type instanceof ReferenceType) {
return asKind(((ReferenceType) type).getType());
} else if(type instanceof UnknownType) {
return TypeKind.OTHER;
} else if(type instanceof VoidType) {
return TypeKind.VOID;
} else if(type instanceof WildcardType) {
return TypeKind.WILDCARD;
}
return TypeKind.ERROR;
}
示例6: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public Node visit(
WildcardType n, Map<Node, Node> arg
) {
if (arg.containsKey(n)) {
return arg.get(n);
}
return super.visit(n, arg);
}
示例7: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public void visit(WildcardType n, Script arg) {
}
示例8: getSocketReturnParam
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
public static Type getSocketReturnParam(String socketNameType) {
ClassOrInterfaceType socketType = new ClassOrInterfaceType(null, socketNameType);
socketType.setTypeArgs(Arrays.asList(new WildcardType()));
return new ReferenceType(socketType, 1);
}
示例9: convertToUsage
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
protected Type convertToUsage(com.github.javaparser.ast.type.Type type, Context context) {
if (type instanceof ClassOrInterfaceType) {
ClassOrInterfaceType classOrInterfaceType = (ClassOrInterfaceType) type;
String name = qName(classOrInterfaceType);
SymbolReference<TypeDeclaration> ref = context.solveType(name, typeSolver);
if (!ref.isSolved()) {
throw new UnsolvedSymbolException(name);
}
TypeDeclaration typeDeclaration = ref.getCorrespondingDeclaration();
List<Type> typeParameters = Collections.emptyList();
if (classOrInterfaceType.getTypeArguments().isPresent()) {
typeParameters = classOrInterfaceType.getTypeArguments().get().stream().map((pt) -> convertToUsage(pt, context)).collect(Collectors.toList());
}
if (typeDeclaration.isTypeParameter()) {
if (typeDeclaration instanceof TypeParameterDeclaration) {
return new TypeVariable((TypeParameterDeclaration) typeDeclaration);
} else {
JavaParserTypeVariableDeclaration javaParserTypeVariableDeclaration = (JavaParserTypeVariableDeclaration) typeDeclaration;
return new TypeVariable(javaParserTypeVariableDeclaration.asTypeParameter());
}
} else {
return new ReferenceTypeImpl((ReferenceTypeDeclaration) typeDeclaration, typeParameters, typeSolver);
}
} else if (type instanceof com.github.javaparser.ast.type.PrimitiveType) {
return PrimitiveType.byName(((com.github.javaparser.ast.type.PrimitiveType) type).getType().name());
} else if (type instanceof WildcardType) {
WildcardType wildcardType = (WildcardType) type;
if (wildcardType.getExtendedTypes().isPresent() && !wildcardType.getSuperTypes().isPresent()) {
return Wildcard.extendsBound(convertToUsage(wildcardType.getExtendedTypes().get(), context)); // removed (ReferenceTypeImpl)
} else if (!wildcardType.getExtendedTypes().isPresent() && wildcardType.getSuperTypes().isPresent()) {
return Wildcard.superBound(convertToUsage(wildcardType.getSuperTypes().get(), context)); // removed (ReferenceTypeImpl)
} else if (!wildcardType.getExtendedTypes().isPresent() && !wildcardType.getSuperTypes().isPresent()) {
return Wildcard.UNBOUNDED;
} else {
throw new UnsupportedOperationException(wildcardType.toString());
}
} else if (type instanceof com.github.javaparser.ast.type.VoidType) {
return VoidType.INSTANCE;
} else if (type instanceof com.github.javaparser.ast.type.ArrayType) {
com.github.javaparser.ast.type.ArrayType jpArrayType = (com.github.javaparser.ast.type.ArrayType) type;
return new ArrayType(convertToUsage(jpArrayType.getComponentType(), context));
} else {
throw new UnsupportedOperationException(type.getClass().getCanonicalName());
}
}
示例10: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public void visit(final WildcardType n, final Context ctx) {
visitNode(n, ctx);
super.visit(n, ctx);
}
示例11: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public Type visit(final WildcardType n, final Context ctx) {
return null;
}
示例12: visit
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public void visit(WildcardType n, Void arg) {
out.println("WildcardType: " + (extended ? n : ""));
super.visit(n, arg);
}
示例13: doIsEquals
import com.github.javaparser.ast.type.WildcardType; //导入依赖的package包/类
@Override
public boolean doIsEquals(WildcardType first, WildcardType second) {
if (!isEqualsUseMerger(first.getExtends(), second.getExtends())) return false;
if (!isEqualsUseMerger(first.getSuper(), second.getSuper())) return false;
return true;
}