Skip to content

Commit

Permalink
Merge pull request #6 from code77se/parameterize-pre-reject
Browse files Browse the repository at this point in the history
Parameterize JQ.reject
  • Loading branch information
code77se committed Apr 21, 2016
2 parents c9106ad + 79a8f69 commit b6758e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions jq/src/main/java/se/code77/jq/JQ.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,15 @@ public V call() throws Exception {

/**
* Create a pre-rejected promise for the given exception
*
*
* @param <T> Type of the value to be carried by the return promise
* @param reason Exception to reject the promise with
* @return A new promise
*/
public static Promise<Void> reject(final Exception reason) {
return defer(new DeferredHandler<Void>() {
public static <T> Promise<T> reject(final Exception reason) {
return defer(new DeferredHandler<T>() {
@Override
public void handle(Deferred<Void> deferred) {
public void handle(Deferred<T> deferred) {
deferred.reject(reason);
}
});
Expand Down
2 changes: 1 addition & 1 deletion jq/src/test/java/se/code77/jq/PromiseTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void delay_isResolved() throws InterruptedException {
@Test
public void delay_isRejected() throws InterruptedException {
// new promise is rejected immediately
Promise<Void> p = JQ.reject(TEST_REASON1).delay(1000);
Promise<Void> p = JQ.<Void>reject(TEST_REASON1).delay(1000);

Thread.sleep(500);
assertRejected(p, TEST_REASON1);
Expand Down

0 comments on commit b6758e3

Please sign in to comment.