.ensureUnique() .build();
/** * Return the unique node selected by running this query against this * {@code ContextManager}'s root context. * <p> * If this query does not return a single unique result then an * {@code IllegalStateException} will be thrown. More details on the query * execution context can be found in {@link #query(Query)}. * * @see #query(Query) * @see QueryBuilder#ensureUnique() * @param query the query to execute * @return the node selected by the query * @throws IllegalStateException if the query does not select a unique node */ public TreeNode queryForSingleton(Query query) throws IllegalStateException { return query(queryBuilder().chain(query).ensureUnique().build()).iterator().next(); }
/** * Return the unique node selected by running this query against this * {@code ContextManager}'s root context. * <p> * If this query does not return a single unique result then an * {@code IllegalStateException} will be thrown. More details on the query * execution context can be found in {@link #query(Query)}. * * @see #query(Query) * @see QueryBuilder#ensureUnique() * @param query the query to execute * @return the node selected by the query * @throws IllegalStateException if the query does not select a unique node */ public TreeNode queryForSingleton(Query query) throws IllegalStateException { return query(queryBuilder().chain(query).ensureUnique().build()).iterator().next(); }
/** * Return the unique node selected by running this query against this * {@code ContextManager}'s root context. * <p> * If this query does not return a single unique result then an * {@code IllegalStateException} will be thrown. More details on the query * execution context can be found in {@link #query(Query)}. * * @see #query(Query) * @see QueryBuilder#ensureUnique() * @param query the query to execute * @return the node selected by the query * @throws IllegalStateException if the query does not select a unique node */ public TreeNode queryForSingleton(Query query) throws IllegalStateException { return query(queryBuilder().chain(query).ensureUnique().build()).iterator().next(); }
/** * Return the unique node selected by running this query against this * {@code ContextManager}'s root context. * <p> * If this query does not return a single unique result then an * {@code IllegalStateException} will be thrown. More details on the query * execution context can be found in {@link #query(Query)}. * * @param query the query to execute * @return the node selected by the query * @throws IllegalStateException if the query does not select a unique node * @see #query(Query) * @see QueryBuilder#ensureUnique() */ public TreeNode queryForSingleton(Query query) throws IllegalStateException { return query(queryBuilder().chain(query).ensureUnique().build()).iterator().next(); }