本文整理汇总了Java中com.github.javaparser.ast.TypeParameter.getName方法的典型用法代码示例。如果您正苦于以下问题:Java TypeParameter.getName方法的具体用法?Java TypeParameter.getName怎么用?Java TypeParameter.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.TypeParameter
的用法示例。
在下文中一共展示了TypeParameter.getName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public Node visit(TypeParameter _n, Object _arg) {
List<ClassOrInterfaceType> typeBound = visit(_n.getTypeBound(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
TypeParameter r = new TypeParameter(_n.getBeginLine(),
_n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getName(), typeBound, annotations);
Comment comment = cloneNodes(_n.getComment(), _arg);
r.setComment(comment);
return r;
}
示例2: absorb
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
public String absorb(TypeParameter type) {
// TODO Only ever allow greater specificity in updates,
// so it is legal to make bounds tighter, but never looser
// Legal: Type<T> -> Type<T extends List>
// Legal: Type<T> -> Type<T, V>
// Illegal: Type<T extends List> -> Type<T>
// TODO: consider whether it should be legal to remove types. Probably not,
// since isolated modules would want to add only names they know about,
// so, absorbing a type parameter should never accidentally erase a type requested elsewhere.
this.type.setTypeBound(type.getTypeBound());
this.type.setName(type.getName());
return type.getName();
}
示例3: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public Node visit(TypeParameter _n, Object _arg) {
List<ClassOrInterfaceType> typeBound = visit(_n.getTypeBound(), _arg);
List<AnnotationExpr> annotations = visit(_n.getAnnotations(), _arg);
TypeParameter r = new TypeParameter(_n.getBeginLine(),
_n.getBeginColumn(), _n.getEndLine(), _n.getEndColumn(),
_n.getName(), typeBound, annotations);
Comment comment = cloneNodes(_n.getComment(), _arg);
r.setComment(comment);
return copyExtras(_n, r);
}
示例4: getJavaType
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
/**
* Resolves the effective {@link JavaType} a
* {@link ClassOrInterfaceDeclaration} represents, including any type
* parameters.
*
* @param compilationUnitService for package management (required)
* @param typeDeclaration the type declaration to resolve (required)
* @return the effective Java type (never null)
*/
public static JavaType getJavaType(
final CompilationUnitService compilationUnitService,
final TypeDeclaration typeDeclaration) {
Validate.notNull(compilationUnitService,
"Compilation unit services required");
Validate.notNull(typeDeclaration, "Type declaration required");
// Convert the ClassOrInterfaceDeclaration name into a JavaType
final NameExpr nameExpr = getNameExpr(typeDeclaration.getName());
final JavaType effectiveType = getJavaType(compilationUnitService,
nameExpr, null);
final List<JavaType> parameterTypes = new ArrayList<JavaType>();
if (typeDeclaration instanceof ClassOrInterfaceDeclaration) {
final ClassOrInterfaceDeclaration clazz = (ClassOrInterfaceDeclaration) typeDeclaration;
// Populate JavaType with type parameters
final List<TypeParameter> typeParameters = clazz
.getTypeParameters();
if (typeParameters != null) {
final Set<JavaSymbolName> locatedTypeParameters = new HashSet<JavaSymbolName>();
for (final TypeParameter candidate : typeParameters) {
final JavaSymbolName currentTypeParam = new JavaSymbolName(
candidate.getName());
locatedTypeParameters.add(currentTypeParam);
JavaType javaType = null;
if (candidate.getTypeBound() == null) {
javaType = new JavaType(
JavaType.OBJECT.getFullyQualifiedTypeName(), 0,
DataType.TYPE, currentTypeParam, null);
}
else {
final ClassOrInterfaceType cit = candidate
.getTypeBound().get(0);
javaType = JavaParserUtils.getJavaTypeNow(
compilationUnitService, cit,
locatedTypeParameters);
javaType = new JavaType(
javaType.getFullyQualifiedTypeName(),
javaType.getArray(), javaType.getDataType(),
currentTypeParam, javaType.getParameters());
}
parameterTypes.add(javaType);
}
}
}
return new JavaType(effectiveType.getFullyQualifiedTypeName(),
effectiveType.getArray(), effectiveType.getDataType(), null,
parameterTypes);
}
示例5: resolveTypeParamName
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
public String resolveTypeParamName(TypeParameter param) {
return param.getName();
}
示例6: resolveTypeParamName
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
/**
* Purposely does not handle bounds; this will be invoked for
* all bounded type arguments (allowing you to perform modifications
* as you see fit).
*/
protected String resolveTypeParamName(TypeParameter typeParam) {
return typeParam.getName();
}