code: public static OwncloudFileResource toOwncloudFileResource(OwncloudResource owncloudResource) throws OwncloudNoFileResourceException {
      if (owncloudResource == null) {
        return null;
      }
      if (isDirectory(owncloudResource) || !ClassUtils.isAssignable(owncloudResource.getClass(), OwncloudFileResource.class)) {
        throw new OwncloudNoFileResourceException(owncloudResource.getHref());
      }
      return (OwncloudFileResource) owncloudResource;
    }
docs: Convert a OwncloudResource to a OwncloudFileResource.
  @param owncloudResource OwncloudResource
  @return converted to OwncloudFileResource
  @throws OwncloudNoFileResourceException if the OwncloudResource is not convertable to a OwncloudFileResource