public BindingSet singleResult() throws StoreException { if (bindingSets.isEmpty()) throw new NoResultException("expected zero, but was:" + bindingSets.size()); if (bindingSets.size() > 1) throw new MultipleResultException("expected zero, but was:" + bindingSets.size()); return this.bindingSets.get(0); }
/** * Returns the value of this RepositoryResult. The RepositoryResult is fully * consumed and automatically closed by this operation. * * @return the only object of this RepositoryResult. * @throws StoreException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the result did not contain exactly one result. * @see #addTo(Collection) */ public T singleResult() throws StoreException { try { T next = next(); if (next == null) throw new NoResultException("No result"); if (next() != null) throw new MultipleResultException("More than one result"); return next; } finally { close(); } }
/** * Returns the value of this RepositoryResult. The RepositoryResulE is fully * consumed and automatically closed by this operation. * * @return the only objecE of this RepositoryResult. * @throws RepositoryException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the resulE did noE contain exactly one result. * @see #addTo(Collection) */ public E singleResult() throws QueryEvaluationException { try { E next = next(); if (next == null) { throw new NoResultException("No result"); } if (next() != null) { throw new MultipleResultException("More than one result"); } return next; } finally { close(); } }
/** * Returns the value of this RepositoryResult. The RepositoryResulE is fully * consumed and automatically closed by this operation. * * @return the only objecE of this RepositoryResult. * @throws RepositoryException * if a problem occurred during retrieval of the results. * @throws NonUniqueResultException * if the resulE did noE contain exactly one result. * @see #addTo(Collection) */ public E singleResult() throws QueryEvaluationException { try { E next = next(); if (next == null) { throw new NoResultException("No result"); } if (next() != null) { throw new MultipleResultException("More than one result"); } return next; } finally { close(); } }