use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class SumFunctionResolver method buildType.
@Override
protected IType buildType() {
IType type = getTypeDeclaration().getType();
TypeHelper helper = getTypeHelper();
// Integral types: int/Integer, long/Long => the result is a Long
if (helper.isIntegralType(type)) {
return helper.longType();
}
// Floating types: float/Float, double/Double => the result is a Double
if (helper.isFloatingType(type)) {
return helper.doubleType();
}
// BigInteger, the result is the same
IType bigIntegerType = helper.bigInteger();
if (type.equals(bigIntegerType)) {
return bigIntegerType;
}
// BigDecimal, the result is the same
IType bigDecimalType = helper.bigDecimal();
if (type.equals(bigDecimalType)) {
return bigDecimalType;
}
// Anything else is an invalid type
return helper.objectType();
}
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(CollectionValuedPathExpression 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);
if (index + 1 < count) {
resolver = buildStateFieldResolver(path);
} else {
resolver = buildCollectionValuedFieldResolver(path);
}
}
}
} else {
resolver = buildNullResolver();
}
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType 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);
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class CollectionEquivalentResolver method buildType.
@Override
protected IType buildType() {
TypeHelper helper = getTypeHelper();
IType unknownType = helper.unknownType();
IType type = null;
for (int index = 0, count = resolvers.size(); index < count; index++) {
IType anotherType = resolvers.get(index).getType();
if (anotherType == unknownType) {
continue;
}
if (type == null) {
type = anotherType;
} else // Two types are not the same, then the type is Object
if (!type.equals(anotherType)) {
return helper.objectType();
}
}
if (type == null) {
type = unknownType;
}
return type;
}
use of org.eclipse.persistence.jpa.jpql.tools.spi.IType in project eclipselink by eclipse-ee4j.
the class AbstractContentAssistExtensionTest method test_enumConstants_07.
@Test
public final void test_enumConstants_07() throws Exception {
String jpqlQuery = "SELECT e FROM Employee e WHERE CASE e.status WHEN jpql.query.EnumType.";
int position = jpqlQuery.length();
IType type = getPersistenceUnit().getTypeRepository().getType(EnumType.class.getName());
List<String> proposals = new ArrayList<>();
CollectionTools.addAll(proposals, type.getEnumConstants());
testHasOnlyTheseProposals(jpqlQuery, position, proposals);
}
Aggregations