Search in sources :

Example 1 with ITypeDeclaration

use of org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration in project eclipselink by eclipse-ee4j.

the class CollectionValuedPathExpressionStateObject method resolveManagedType.

@Override
protected IManagedType resolveManagedType() {
    IMapping mapping = getMapping();
    if (mapping == null) {
        return null;
    }
    TypeHelper typeHelper = getTypeHelper();
    ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
    IType type = typeDeclaration.getType();
    // it cannot be traversed
    if (typeHelper.isCollectionType(type)) {
        return null;
    }
    // Primitive types cannot have a managed type
    if (typeHelper.isPrimitiveType(type)) {
        return null;
    }
    // Retrieve the corresponding managed type for the mapping's type
    return getManagedTypeProvider().getManagedType(type);
}
Also used : TypeHelper(org.eclipse.persistence.jpa.jpql.tools.TypeHelper) ITypeDeclaration(org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration) IMapping(org.eclipse.persistence.jpa.jpql.tools.spi.IMapping) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType)

Example 2 with ITypeDeclaration

use of org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration in project eclipselink by eclipse-ee4j.

the class CollectionValuedPathExpressionStateObject method resolveType.

@Override
protected IType resolveType() {
    TypeHelper typeHelper = getTypeHelper();
    ITypeDeclaration typeDeclaration = getTypeDeclaration();
    IType type = typeDeclaration.getType();
    // For a collection type, return the first type parameter
    if (typeHelper.isCollectionType(type)) {
        ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
        if (typeParameters.length > 0) {
            type = typeParameters[0].getType();
        }
    } else // For a map type, by default the value is the actual type to return
    if (typeHelper.isMapType(type)) {
        ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
        if (typeParameters.length == 2) {
            type = typeParameters[1].getType();
        }
    }
    // only deals with the primitive wrapper type
    return typeHelper.convertPrimitive(type);
}
Also used : TypeHelper(org.eclipse.persistence.jpa.jpql.tools.TypeHelper) ITypeDeclaration(org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType)

Example 3 with ITypeDeclaration

use of org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration in project eclipselink by eclipse-ee4j.

the class CollectionValuedFieldResolver method buildType.

@Override
protected IType buildType() {
    ITypeDeclaration typeDeclaration = getTypeDeclaration();
    IType type = typeDeclaration.getType();
    // For a collection type, return the first type parameter
    if (getTypeHelper().isCollectionType(type)) {
        ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
        if (typeParameters.length > 0) {
            type = typeParameters[0].getType();
        }
    } else // For a map type, by default the value is the actual type to return
    if (getTypeHelper().isMapType(type)) {
        ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
        if (typeParameters.length == 2) {
            type = typeParameters[1].getType();
        }
    }
    // only deals with the primitive wrapper type
    return getTypeHelper().convertPrimitive(type);
}
Also used : ITypeDeclaration(org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType)

Example 4 with ITypeDeclaration

use of org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration in project eclipselink by eclipse-ee4j.

the class StateFieldResolver method resolveManagedType.

@Override
protected IManagedType resolveManagedType(IMapping mapping) {
    ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
    IType type = typeDeclaration.getType();
    // it cannot be traversed
    if (getTypeHelper().isCollectionType(type)) {
        return null;
    }
    // Primitive types cannot have a managed type
    if (getTypeHelper().isPrimitiveType(type)) {
        return null;
    }
    // Retrieve the corresponding managed type for the mapping's type
    return getProvider().getManagedType(type);
}
Also used : ITypeDeclaration(org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType)

Example 5 with ITypeDeclaration

use of org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration in project eclipselink by eclipse-ee4j.

the class StateFieldPathExpressionStateObject method resolveManagedType.

@Override
protected IManagedType resolveManagedType() {
    IMapping mapping = getMapping();
    if (mapping == null) {
        return null;
    }
    TypeHelper typeHelper = getTypeHelper();
    ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
    IType type = typeDeclaration.getType();
    // Collection type cannot be traversed
    if (typeHelper.isCollectionType(type)) {
        ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
        if (typeParameters.length == 0) {
            return null;
        }
        type = typeParameters[0].getType();
    } else // IType for the Map can be used to retrieve the type of the key and value
    if (typeHelper.isMapType(type)) {
        return new MapManagedType(getManagedTypeProvider(), type);
    }
    // Retrieve the corresponding managed type for the mapping's type
    return getManagedTypeProvider().getManagedType(type);
}
Also used : TypeHelper(org.eclipse.persistence.jpa.jpql.tools.TypeHelper) ITypeDeclaration(org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration) IMapping(org.eclipse.persistence.jpa.jpql.tools.spi.IMapping) IType(org.eclipse.persistence.jpa.jpql.tools.spi.IType)

Aggregations

ITypeDeclaration (org.eclipse.persistence.jpa.jpql.tools.spi.ITypeDeclaration)8 IType (org.eclipse.persistence.jpa.jpql.tools.spi.IType)7 TypeHelper (org.eclipse.persistence.jpa.jpql.tools.TypeHelper)3 IMapping (org.eclipse.persistence.jpa.jpql.tools.spi.IMapping)2 GenericArrayType (java.lang.reflect.GenericArrayType)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 WildcardType (java.lang.reflect.WildcardType)1 ArrayList (java.util.ArrayList)1