public function withQuery($query)
    {
        $new = clone $this;
        try {
            $new->setQuery($query);
        } catch (InvalidArgumentException $ex) {
            throw new InvalidArgumentException('Invalid query provided.', null, $ex);
        }

        return $new;
    }