use of com.querydsl.core.types.ExpressionException in project querydsl by querydsl.
the class CollectionPathBase method newInstance.
@SuppressWarnings("unchecked")
protected Q newInstance(Class<Q> queryType, PathMetadata pm) {
try {
if (constructor == null) {
if (Constants.isTyped(queryType)) {
try {
constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class, PathInits.class);
usePathInits = true;
} catch (NoSuchMethodException e) {
constructor = queryType.getDeclaredConstructor(Class.class, PathMetadata.class);
}
} else {
try {
constructor = queryType.getDeclaredConstructor(PathMetadata.class, PathInits.class);
usePathInits = true;
} catch (NoSuchMethodException e) {
constructor = queryType.getDeclaredConstructor(PathMetadata.class);
}
}
constructor.setAccessible(true);
}
if (Constants.isTyped(queryType)) {
if (usePathInits) {
return (Q) constructor.newInstance(getElementType(), pm, inits);
} else {
return (Q) constructor.newInstance(getElementType(), pm);
}
} else {
if (usePathInits) {
return (Q) constructor.newInstance(pm, inits);
} else {
return (Q) constructor.newInstance(pm);
}
}
} catch (NoSuchMethodException e) {
throw new ExpressionException(e);
} catch (InstantiationException e) {
throw new ExpressionException(e);
} catch (IllegalAccessException e) {
throw new ExpressionException(e);
} catch (InvocationTargetException e) {
throw new ExpressionException(e);
}
}
Aggregations