Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
azatsarynnyy committed Apr 8, 2015
1 parent 95d9742 commit edd5c95
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

/**
* Function interface.
*
* @param <A> the argument type
* @param <R> the result type
*
* @param <A>
* the argument type
* @param <R>
* the result type
*/
public interface Function<A, R> {
R apply(A arg) throws FunctionException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
/**
* Interface for an 'operation', as a function without a return value, only side-effects, but without the burden of having a callback with
* Void parameter.
*
* @param <A> the type of the argument
*
* @param <A>
* the type of the argument
*/
public interface Operation<A> {
void apply(A arg) throws OperationException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
/**
* The executor is the conclusion callback, a js function with two parameters, usually named
* resolve and reject. The first argument fulfills the promise, the second argument rejects it.
* @param <V> the type of the promised value
*
* @param <V>
* the type of the promised value
*/
public class Executor<V> extends JavaScriptObject {

/** JSO mandated protected constructor. */
protected Executor() {}
protected Executor() {
}

/*
* The first parameter is the fulfillment function, the second is the rejection function. Both
Expand All @@ -32,12 +35,15 @@ protected Executor() {}

/**
* Creates an executor.
* @param executorBody the body of the executor
*
* @param executorBody
* the body of the executor
* @param <V>
* the fulfillment value
* @return the new executor
* @param <V> the fulfillment value
*/
public static final native <V> Executor<V> create(ExecutorBody<V> executorBody) /*-{
return function(resolve, reject) {
return function (resolve, reject) {
try {
executorBody.@org.eclipse.che.api.promises.client.js.Executor.ExecutorBody::apply(*)(resolve, reject);
} catch (e) {
Expand All @@ -48,15 +54,20 @@ public static final native <V> Executor<V> create(ExecutorBody<V> executorBody)

/**
* The definition of an executor.
* @param <V> the type of the fulfillment value
*
* @param <V>
* the type of the fulfillment value
*/
public interface ExecutorBody<V> {
/**
* The executor describes what the promise must do in order to be fulfilled.
* It will execute some code to process or retrieve some value, then use the <code>resolve</code> or
* <code>reject</code> callback to conclude.
* @param resolve what to do on success
* @param reject what to do on failure
*
* @param resolve
* what to do on success
* @param reject
* what to do on failure
*/
void apply(ResolveFunction<V> resolve, RejectFunction reject);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
*******************************************************************************/
package org.eclipse.che.api.promises.client.js;

import org.eclipse.che.api.promises.client.PromiseError;
import com.google.gwt.core.client.JavaScriptObject;

import org.eclipse.che.api.promises.client.PromiseError;

public class JsPromiseError extends JavaScriptObject implements PromiseError {

protected JsPromiseError() {
Expand Down Expand Up @@ -40,10 +41,10 @@ public static final JsPromiseError create(final Throwable e) {
if (stack != null && stack.length != 0) {
result = create(e.getMessage(), stack[0].getFileName(), Integer.toString(stack[0].getLineNumber()));
result.setStack(stack);
} else {
result = create(e.getMessage());
}
return result;
} else {
result = create(e.getMessage());
}
return result;
}

private final void setStack(final StackTraceElement[] stack) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@
*******************************************************************************/
package org.eclipse.che.api.promises.client.js;

import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.promises.client.PromiseError;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayMixed;

import elemental.js.util.JsArrayOf;
import elemental.util.ArrayOf;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArrayMixed;

import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.promises.client.PromiseError;

public final class Promises {

/** Private constructor, the class is not instantiable. */
private Promises() {}
private Promises() {
}

/**
* Creates a new promise using the provided executor.
* @param conclusion the executor
*
* @param conclusion
* the executor
* @param <V>
* the type of the promised value
* @return a promise
* @param <V> the type of the promised value
*/
public static final native <V> JsPromise<V> create(Executor<V> conclusion) /*-{
return new Promise(conclusion);
Expand All @@ -37,7 +41,9 @@ public static final native <V> JsPromise<V> create(Executor<V> conclusion) /*-{
/**
* Creates a promise that resolves as soon as all the promises used as parameters are resolved or rejected
* as soon as the first rejection happens on one of the included promises.
* @param promises the included promises
*
* @param promises
* the included promises
* @return a promise with an array of unit values as fulfillment value
*/
public static final native JsPromise<JsArrayMixed> all(ArrayOf<Promise<?>> promises) /*-{
Expand All @@ -46,7 +52,7 @@ public static final native JsPromise<JsArrayMixed> all(ArrayOf<Promise<?>> promi

public static final JsPromise<JsArrayMixed> all(final Promise<?>... promises) {
final JsArrayOf<Promise<?>> promisesArray = JavaScriptObject.createArray().cast();
for (final Promise<?> promise: promises) {
for (final Promise<?> promise : promises) {
promisesArray.push(promise);
}
return all(promisesArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
*******************************************************************************/
package org.eclipse.che.api.promises.client.js;

import org.eclipse.che.api.promises.client.PromiseError;
import com.google.gwt.core.client.JavaScriptObject;

import org.eclipse.che.api.promises.client.PromiseError;

public class RejectFunction extends JavaScriptObject {

protected RejectFunction() {
Expand Down

0 comments on commit edd5c95

Please sign in to comment.