Skip to content

Commit

Permalink
Merge pull request #3 from Scalified/develop
Browse files Browse the repository at this point in the history
RELEASE 0.0.4
  • Loading branch information
vbaidak authored Apr 6, 2018
2 parents 2d0c456 + cb80afb commit 1d076b0
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 10 deletions.
18 changes: 11 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
# 0.0.1
# 0.0.4

* [**#1** Add Equals, HashCode and toString Methods To Request Object](https://github.com/Scalified/rest/issues/1)

# 0.0.3

## Features

* JAX-RS client
* CORS Filter
* Extended **HTTP** headers, media types and statuses
* Resteasy multipart utilities
* Changed JAX-RS dependency scope

# 0.0.2

## Features

* UriUtils - utility extensions for java.lang.URI

# 0.0.3
# 0.0.1

## Features

* Changed JAX-RS dependency scope
* JAX-RS client
* CORS Filter
* Extended **HTTP** headers, media types and statuses
* Resteasy multipart utilities
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ The Library consists of several modules, which can be used separately

```java
dependencies {
compile 'com.scalified:jaxrs:0.0.3'
compile 'com.scalified:jaxrs:0.0.4'
}
```

### jaxrs-resteasy3

```java
dependencies {
compile 'com.scalified:jaxrs-resteasy3:0.0.3'
compile 'com.scalified:jaxrs-resteasy3:0.0.4'

compileOnly "org.jboss.resteasy:resteasy-multipart-provider:3.0.1.Final"
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.nio.charset.StandardCharsets
allprojects {

group = 'com.scalified'
version = '0.0.3'
version = '0.0.4'

repositories {
mavenCentral()
Expand Down
241 changes: 241 additions & 0 deletions jaxrs/src/main/java/com/scalified/rest/jaxrs/client/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,96 @@ public class Request {
*/
Consumer<Throwable> failureConsumer;

/**
* Returns request URL
*
* @return request URL
*/
public String getUrl() {
return url;
}

/**
* Returns request path parameters
*
* @return request path parameters
*/
public Collection<String> getPathParams() {
return pathParams;
}

/**
* Returns request query parameters
*
* @return request query parameters
*/
public Map<String, Collection<?>> getQueryParams() {
return queryParams;
}

/**
* Returns request headers
*
* @return request headers
*/
public Map<String, Object> getHeaders() {
return headers;
}

/**
* Returns request accepted media types
*
* @return request accepted media types
*/
public Set<MediaType> getMediaTypes() {
return mediaTypes;
}

/**
* Returns request entity
*
* @return request entity
*/
public Entity<?> getEntity() {
return entity;
}

/**
* Returns response consumer for successful <b>HTTP</b> response
*
* @return response consumer for successful <b>HTTP</b> response
*/
public Consumer<Response> getSuccessConsumer() {
return successConsumer;
}

/**
* Returns response consumer for <b>HTTP</b> response having {@link Response.Status#NOT_FOUND} status
*
* @return response consumer for <b>HTTP</b> response having {@link Response.Status#NOT_FOUND} status
*/
public Consumer<Response> getNotFoundConsumer() {
return notFoundConsumer;
}

/**
* Returns response consumer for <b>HTTP</b> response having unsuccessful response
*
* @return response consumer for <b>HTTP</b> response having unsuccessful response
*/
public Consumer<Response> getUnsuccessfulResponseConsumer() {
return unsuccessfulResponseConsumer;
}

/**
* Returns response consumer for exceptional case
*
* @return response consumer for exceptional case
*/
public Consumer<Throwable> getFailureConsumer() {
return failureConsumer;
}

/**
* Returns the <b>HTTP</b> {@link Request} builder
*
Expand All @@ -101,6 +191,157 @@ public static Builder builder(String url) {
return new Builder(url);
}

/**
* Indicates whether some other object is "equal to" this one.
* <p>
* The {@code equals} method implements an equivalence relation
* on non-null object references:
* <ul>
* <li>It is <i>reflexive</i>: for any non-null reference value
* {@code x}, {@code x.equals(x)} should return
* {@code true}.
* <li>It is <i>symmetric</i>: for any non-null reference values
* {@code x} and {@code y}, {@code x.equals(y)}
* should return {@code true} if and only if
* {@code y.equals(x)} returns {@code true}.
* <li>It is <i>transitive</i>: for any non-null reference values
* {@code x}, {@code y}, and {@code z}, if
* {@code x.equals(y)} returns {@code true} and
* {@code y.equals(z)} returns {@code true}, then
* {@code x.equals(z)} should return {@code true}.
* <li>It is <i>consistent</i>: for any non-null reference values
* {@code x} and {@code y}, multiple invocations of
* {@code x.equals(y)} consistently return {@code true}
* or consistently return {@code false}, provided no
* information used in {@code equals} comparisons on the
* objects is modified.
* <li>For any non-null reference value {@code x},
* {@code x.equals(null)} should return {@code false}.
* </ul>
* <p>
* The {@code equals} method for class {@code Object} implements
* the most discriminating possible equivalence relation on objects;
* that is, for any non-null reference values {@code x} and
* {@code y}, this method returns {@code true} if and only
* if {@code x} and {@code y} refer to the same object
* ({@code x == y} has the value {@code true}).
* <p>
* Note that it is generally necessary to override the {@code hashCode}
* method whenever this method is overridden, so as to maintain the
* general contract for the {@code hashCode} method, which states
* that equal objects must have equal hash codes.
*
* @param obj the reference object with which to compare.
* @return {@code true} if this object is the same as the obj
* argument; {@code false} otherwise.
* @see #hashCode()
* @see java.util.HashMap
*/
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null || getClass() != obj.getClass()) return false;
Request request = (Request) obj;
return Objects.equals(url, request.url) &&
Objects.equals(pathParams, request.pathParams) &&
Objects.equals(queryParams, request.queryParams) &&
Objects.equals(headers, request.headers) &&
Objects.equals(mediaTypes, request.mediaTypes) &&
Objects.equals(entity, request.entity) &&
Objects.equals(successConsumer, request.successConsumer) &&
Objects.equals(notFoundConsumer, request.notFoundConsumer) &&
Objects.equals(unsuccessfulResponseConsumer, request.unsuccessfulResponseConsumer) &&
Objects.equals(failureConsumer, request.failureConsumer);
}

/**
* Returns a hash code value for the object. This method is
* supported for the benefit of hash tables such as those provided by
* {@link java.util.HashMap}.
* <p>
* The general contract of {@code hashCode} is:
* <ul>
* <li>Whenever it is invoked on the same object more than once during
* an execution of a Java application, the {@code hashCode} method
* must consistently return the same integer, provided no information
* used in {@code equals} comparisons on the object is modified.
* This integer need not remain consistent from one execution of an
* application to another execution of the same application.
* <li>If two objects are equal according to the {@code equals(Object)}
* method, then calling the {@code hashCode} method on each of
* the two objects must produce the same integer result.
* <li>It is <em>not</em> required that if two objects are unequal
* according to the {@link java.lang.Object#equals(java.lang.Object)}
* method, then calling the {@code hashCode} method on each of the
* two objects must produce distinct integer results. However, the
* programmer should be aware that producing distinct integer results
* for unequal objects may improve the performance of hash tables.
* </ul>
* <p>
* As much as is reasonably practical, the hashCode method defined by
* class {@code Object} does return distinct integers for distinct
* objects. (This is typically implemented by converting the internal
* address of the object into an integer, but this implementation
* technique is not required by the
* Java&trade; programming language.)
*
* @return a hash code value for this object.
* @see java.lang.Object#equals(java.lang.Object)
* @see java.lang.System#identityHashCode
*/
@Override
public int hashCode() {
return Objects.hash(
url,
pathParams,
queryParams,
headers,
mediaTypes,
entity,
successConsumer,
notFoundConsumer,
unsuccessfulResponseConsumer,
failureConsumer
);
}

/**
* Returns a string representation of the object. In general, the
* {@code toString} method returns a string that
* "textually represents" this object. The result should
* be a concise but informative representation that is easy for a
* person to read.
* It is recommended that all subclasses override this method.
* <p>
* The {@code toString} method for class {@code Object}
* returns a string consisting of the name of the class of which the
* object is an instance, the at-sign character `{@code @}', and
* the unsigned hexadecimal representation of the hash code of the
* object. In other words, this method returns a string equal to the
* value of:
* <blockquote>
* <pre>
* getClass().getName() + '@' + Integer.toHexString(hashCode())
* </pre></blockquote>
*
* @return a string representation of the object.
*/
@Override
public String toString() {
return "Request{" +
"url='" + url + '\'' +
", pathParams=" + pathParams +
", queryParams=" + queryParams +
", headers=" + headers +
", mediaTypes=" + mediaTypes +
", entity=" + entity +
", successConsumer=" + successConsumer +
", notFoundConsumer=" + notFoundConsumer +
", unsuccessfulResponseConsumer=" + unsuccessfulResponseConsumer +
", failureConsumer=" + failureConsumer +
'}';
}

/**
* <b>HTTP</b> {@link Request} builder
*/
Expand Down

0 comments on commit 1d076b0

Please sign in to comment.