Java Code Examples for com.github.javaparser.resolution.types.ResolvedType#isReferenceType()

The following examples show how to use com.github.javaparser.resolution.types.ResolvedType#isReferenceType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FieldHelper.java    From apigcc with MIT License 6 votes vote down vote up
/**
 * 获取真实的属性类型
 * @param parent
 * @param field
 * @return
 */
public static ResolvedType getActuallyType(ResolvedReferenceType parent, ResolvedFieldDeclaration field) {
    ResolvedType type = field.getType();
    if (type.isReferenceType()) {
        //将父类的T,传递给 属性的T
        return ClassHelper.useClassTypeParameter(parent, type.asReferenceType());
    }
    if (type.isTypeVariable()) {
        //类型为T,这种泛型
        Optional<ResolvedType> optional = ClassHelper.getTypeParameter(parent, field.getType().asTypeParameter().getName());
        if (optional.isPresent()) {
            return optional.get();
        }
    }
    return type;
}
 
Example 2
Source File: PrimitiveTypeResolver.java    From apigcc with MIT License 5 votes vote down vote up
/**
 * 包装类型判断
 *
 * @param type
 * @return
 */
private boolean isBoxing(ResolvedType type) {
    if (!type.isReferenceType()) {
        return false;
    }
    String id = type.asReferenceType().getId();
    return list.contains(id);
}
 
Example 3
Source File: SchemaResolver.java    From flow with Apache License 2.0 5 votes vote down vote up
private boolean isTypeOf(ResolvedType type, Class... clazz) {
    if (!type.isReferenceType()) {
        return false;
    }
    List<String> classes = Arrays.stream(clazz).map(Class::getName)
            .collect(Collectors.toList());
    return classes.contains(type.asReferenceType().getQualifiedName())
            || type.asReferenceType().getAllAncestors().stream()
                    .map(ResolvedReferenceType::getQualifiedName)
                    .anyMatch(classes::contains);
}
 
Example 4
Source File: SchemaResolver.java    From flow with Apache License 2.0 5 votes vote down vote up
private Schema createUserBeanSchema(ResolvedType resolvedType) {
    if (resolvedType.isReferenceType()) {
        String qualifiedName = resolvedType.asReferenceType()
                .getQualifiedName();
        foundTypes.put(qualifiedName, resolvedType.asReferenceType());
        return new ObjectSchema().name(qualifiedName)
                .$ref(getFullQualifiedNameRef(qualifiedName));
    }
    return new ObjectSchema();
}
 
Example 5
Source File: ObjectTypeResolver.java    From apigcc with MIT License 4 votes vote down vote up
@Override
public boolean accept(ResolvedType type) {
    return type.isReferenceType();
}
 
Example 6
Source File: ReferenceTypeResolver.java    From apigcc with MIT License 4 votes vote down vote up
@Override
public boolean accept(ResolvedType type) {
    return type.isReferenceType() &&
            !Apigcc.getInstance().getContext().hasCodeTypeDeclaration(type.asReferenceType().getId());
}
 
Example 7
Source File: SchemaResolver.java    From flow with Apache License 2.0 4 votes vote down vote up
private boolean isOptionalType(ResolvedType resolvedType) {
    return resolvedType.isReferenceType()
            && isTypeOf(resolvedType, Optional.class);
}
 
Example 8
Source File: SchemaResolver.java    From flow with Apache License 2.0 4 votes vote down vote up
private boolean isUnhandledJavaType(ResolvedType resolvedType) {
    return resolvedType.isReferenceType() && resolvedType.asReferenceType()
            .getQualifiedName().startsWith("java.");
}
 
Example 9
Source File: SchemaResolver.java    From flow with Apache License 2.0 4 votes vote down vote up
private boolean isDateTimeType(ResolvedType resolvedType) {
    return resolvedType.isReferenceType()
            && isTypeOf(resolvedType, LocalDateTime.class, Instant.class);
}
 
Example 10
Source File: SchemaResolver.java    From flow with Apache License 2.0 4 votes vote down vote up
private boolean isDateType(ResolvedType resolvedType) {
    return resolvedType.isReferenceType()
            && isTypeOf(resolvedType, Date.class, LocalDate.class);
}