use of org.apache.jena.enhanced.UnsupportedPolymorphismException in project jena by apache.
the class SecuredRDFNodeImpl method as.
@SuppressWarnings("unchecked")
@Override
public <T extends RDFNode> T as(final Class<T> view) throws ReadDeniedException, AuthenticationRequiredException, SecuredUnsupportedPolymorphismException {
checkRead();
// see if the base Item can as
T baseAs = holder.getBaseItem().as(view);
if (view.equals(SecuredRDFNodeImpl.class) || view.equals(RDFNode.class)) {
return (T) this;
}
final Method m = getConstructor(view);
if (m == null) {
throw new SecuredUnsupportedPolymorphismException(this, view);
}
try {
return (T) m.invoke(null, securedModel, baseAs);
} catch (final UnsupportedPolymorphismException e) {
throw new SecuredUnsupportedPolymorphismException(this, view);
} catch (final IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (final IllegalAccessException e) {
throw new RuntimeException(e);
} catch (final InvocationTargetException e) {
throw new RuntimeException(e);
}
}
Aggregations