use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class ResolverBuilder method visit.
@Override
public void visit(StateFieldPathExpression expression) {
// so we can't resolve the type
if (!expression.endsWithDot()) {
// Check first to see if it's an enum type
String path = expression.toActualText();
IType type = queryContext.getTypeRepository().getEnumType(path);
if (type != null) {
resolver = buildEnumResolver(expression, type, path);
} else {
expression.getIdentificationVariable().accept(this);
for (int index = expression.hasVirtualIdentificationVariable() ? 0 : 1, count = expression.pathSize(); index < count; index++) {
path = expression.getPath(index);
resolver = buildStateFieldResolver(expression.getPath(index));
}
}
} else {
resolver = buildNullResolver();
}
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType 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);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType 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);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class CollectionValuedFieldResolver method resolveManagedType.
@Override
protected IManagedType resolveManagedType(IMapping mapping) {
ITypeDeclaration typeDeclaration = mapping.getTypeDeclaration();
IType type = typeDeclaration.getType();
// Collection type cannot be traversed
if (getTypeHelper().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 (getTypeHelper().isMapType(type)) {
ITypeDeclaration[] typeParameters = typeDeclaration.getTypeParameters();
if (typeParameters.length != 2) {
return null;
}
type = typeParameters[1].getType();
}
// Retrieve the corresponding managed type for the mapping's type
return getProvider().getManagedType(type);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class NumericResolver method buildType.
@Override
protected IType buildType() {
List<IType> types = new ArrayList<>(resolvers.size());
TypeHelper helper = getTypeHelper();
IType unresolvableType = helper.unknownType();
// Convert any primitive types into its Class type and any non-number into Object
for (Resolver typeResolver : resolvers) {
IType type = typeResolver.getType();
// Only a resolvable type will be added to the list
if (type != unresolvableType) {
// Non-numeric type cannot be added
if (!helper.isNumericType(type)) {
type = helper.objectType();
}
types.add(type);
}
}
if (types.isEmpty()) {
return helper.unknownType();
}
// Comparing the types will result in putting the
// result at the beginning of the list
Collections.sort(types, new NumericTypeComparator(helper));
return types.get(0);
}
Aggregations