@Override public boolean matches(final NormalisedPath requestPath) { if (this.numberOfParts() != requestPath.numberOfParts()) { return false; } for (int i = 0; i < this.numberOfParts(); i++) { if (!this.partMatches(i, requestPath.part(i))) { return false; } } return true; }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method PATCH and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder patch(final String path) { return new Builder(Method.PATCH, path); }
/** * Creates a {@link SimpleResponse.Builder} with the given HTTP status code. * * @param status the responses HTTP status code * @return a prepared {@link SimpleResponse.Builder} */ public static Builder status(final int status) { return new Builder(status); }
/** * Sets the content type header on this builder. * <p> * Equivalent to: <pre>withHeader("Content-Type", contentType);</pre> * * @param contentType The content type to set * * @return this builder */ public Builder withContentType(final String contentType) { return withHeader(CONTENT_TYPE, contentType); }
@Override public int getStatus() { return delegate.getStatus(); }
/** * Sets the content type header on this builder. * <p> * Equivalent to: <pre>withHeader("Content-Type", contentType);</pre> * * @param contentType The content type to set * * @return this builder */ public Builder withContentType(final String contentType) { return withHeader(CONTENT_TYPE, contentType); }
/** * Creates a {@link SimpleResponse.Builder} with the given HTTP status code. * * @param status the responses HTTP status code */ public Builder(final int status) { this.status = status; headers = SimpleRequest.Builder.multimapBuilder(false /* header are always case insensitive */); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method PUT and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder put(final String path) { return new Builder(Method.PUT, path); }
/** * A convenience method for creating a {@link SimpleResponse.Builder} with * the HTTP status code 400. * * @return a prepared {@link SimpleResponse.Builder} */ public static Builder badRequest() { return new Builder(400); }
/** * Sets the accept header on this builder. * <p> * Equivalent to: <pre>withHeader("Accept", contentType);</pre> * * @param accept The accept type(s) to set * * @return this builder */ public Builder withAccept(final String... accept) { return withHeader(ACCEPT, accept); }
@Override public int getStatus() { return delegate.getStatus(); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method DELETE and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder delete(final String path) { return new Builder(Method.DELETE, path); }
/** * A convenience method for creating a {@link SimpleResponse.Builder} with * the HTTP status code 200. * * @return a prepared {@link SimpleResponse.Builder} */ public static Builder ok() { return new Builder(200); }
/** * Sets the authorization header on this builder. * <p> * Equivalent to: <pre>withHeader("Authorization", contentType);</pre> * * @param auth The authorization header to set * * @return this builder */ public Builder withAuthorization(final String auth) { return withHeader(AUTHORIZATION, auth); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method GET and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder get(final String path) { return new Builder(Method.GET, path); }
/** * A convenience method for creating a {@link SimpleResponse.Builder} with * the HTTP status code 204. * * @return a prepared {@link SimpleResponse.Builder} */ public static Builder noContent() { return new Builder(204); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method POST and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder post(final String path) { return new Builder(Method.POST, path); }
/** * A convenience method for creating a {@link SimpleResponse.Builder} with * the HTTP status code 500. * * @return a prepared {@link SimpleResponse.Builder} */ public static Builder serverError() { return new Builder(500); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method HEAD and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder head(final String path) { return new Builder(Method.HEAD, path); }
/** * A convenience method for creating a {@link SimpleRequest.Builder} with * HTTP method OPTIONS and the given path. * * @param path the requests path * @return a prepared {@link SimpleRequest.Builder} */ public static Builder options(final String path) { return new Builder(Method.OPTIONS, path); }