本文整理汇总了Java中com.github.javaparser.ast.TypeParameter.getTypeBound方法的典型用法代码示例。如果您正苦于以下问题:Java TypeParameter.getTypeBound方法的具体用法?Java TypeParameter.getTypeBound怎么用?Java TypeParameter.getTypeBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.javaparser.ast.TypeParameter
的用法示例。
在下文中一共展示了TypeParameter.getTypeBound方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public void visit(final TypeParameter n, final Object arg) {
printer.printLn("TypeParameter");
printJavaComment(n.getComment(), arg);
if (n.getAnnotations() != null) {
for (AnnotationExpr ann : n.getAnnotations()) {
ann.accept(this, arg);
printer.print(" ");
}
}
printer.print(n.getName());
if (n.getTypeBound() != null) {
printer.print(" extends ");
for (final Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext(); ) {
final ClassOrInterfaceType c = i.next();
c.accept(this, arg);
if (i.hasNext()) {
printer.print(" & ");
}
}
}
}
示例2: doIsEquals
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public boolean doIsEquals(TypeParameter first, TypeParameter second) {
if(!StringUtils.equals(first.getName(),second.getName())) return false;
List<ClassOrInterfaceType> firstTypeBounds = first.getTypeBound();
List<ClassOrInterfaceType> secondTypeBounds = second.getTypeBound();
if(firstTypeBounds == null) return secondTypeBounds == null;
if(secondTypeBounds == null) return false;
if(firstTypeBounds.size() != secondTypeBounds.size()) return false;
AbstractMerger<ClassOrInterfaceType> merger = getMerger(ClassOrInterfaceType.class);
for(int i = 0; i < firstTypeBounds.size(); i++){
if(!merger.isEquals(firstTypeBounds.get(i),secondTypeBounds.get(i))){
return false;
}
}
return true;
}
示例3: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override public void visit(final TypeParameter n, final Object arg) {
printJavaComment(n.getComment(), arg);
if (n.getAnnotations() != null) {
for (AnnotationExpr ann : n.getAnnotations()) {
ann.accept(this, arg);
printer.print(" ");
}
}
printer.print(n.getName());
if (n.getTypeBound() != null) {
printer.print(" extends ");
for (final Iterator<ClassOrInterfaceType> i = n.getTypeBound().iterator(); i.hasNext();) {
final ClassOrInterfaceType c = i.next();
c.accept(this, arg);
if (i.hasNext()) {
printer.print(" & ");
}
}
}
}
示例4: typeVariableName
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
private TypeVariableName typeVariableName(TypeParameter typeParameter, TypeNameDetermination typeNameDetermination) {
List<ClassOrInterfaceType> typeBounds = typeParameter.getTypeBound();
TypeName[] typeNames = typeBounds.stream()
.map(typeNameDetermination::determineTypeName)
.toArray(TypeName[]::new);
return TypeVariableName.get(typeParameter.getName(), typeNames);
}
示例5: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public JCTree visit(final TypeParameter n, final Object arg) {
//ARG0: Name name
Name arg0 = names.fromString(n.getName());
//ARG1: List<JCExpression> bounds
List<JCExpression> arg1 = List.<JCExpression>nil();
if (n.getTypeBound() != null) {
for (final ClassOrInterfaceType c : n.getTypeBound()) {
arg1 = arg1.append((JCExpression) c.accept(this, arg));
}
}
return new AJCTypeParameter(make.TypeParameter(arg0, arg1), ((n.getComment() != null) ? n.getComment().getContent() : null));
}
示例6: apply
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
public TypeRef apply(TypeParameter item) {
List<TypeRef> interfaces = new ArrayList<TypeRef>();
for (ClassOrInterfaceType classOrInterfaceType : item.getTypeBound()) {
}
return null;
}
示例7: apply
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
public TypeParamDef apply(TypeParameter typeParameter) {
List<ClassRef> bounds = new ArrayList<ClassRef>();
for (ClassOrInterfaceType classOrInterfaceType : typeParameter.getTypeBound()) {
bounds.add((ClassRef) CLASS_OR_TYPEPARAM_REF.apply(classOrInterfaceType));
}
return new TypeParamDefBuilder()
.withName(typeParameter.getName())
.withBounds(bounds)
.build();
}
示例8: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override
public R visit(final TypeParameter n, final A arg) {
if (n.getTypeBound() != null) {
for (final ClassOrInterfaceType c : n.getTypeBound()) {
{
R result = c.accept(this, arg);
if (result != null) {
return result;
}
}
}
}
return null;
}
示例9: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override public void visit(final TypeParameter n, final A arg) {
visitComment(n.getComment(), arg);
if (n.getTypeBound() != null) {
for (final ClassOrInterfaceType c : n.getTypeBound()) {
c.accept(this, arg);
}
}
}
示例10: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override public void visit(final TypeParameter n, final A arg) {
jw.write(n);
visitComment(n.getComment(), arg);
if (n.getTypeBound() != null) {
for (final ClassOrInterfaceType c : n.getTypeBound()) {
c.accept(this, arg);
}
}
}
示例11: visit
import com.github.javaparser.ast.TypeParameter; //导入方法依赖的package包/类
@Override public Node visit(final TypeParameter n, final A arg) {
final List<ClassOrInterfaceType> typeBound = n.getTypeBound();
if (typeBound != null) {
for (int i = 0; i < typeBound.size(); i++) {
typeBound.set(i, (ClassOrInterfaceType) typeBound.get(i).accept(this, arg));
}
removeNulls(typeBound);
}
return n;
}
示例12: 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);
}