<commit_before>package com.java_promise.genericpromise;

import com.java_promise.common.RejectCallback;
import com.java_promise.common.State;

import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;

/**
 * Created by Philip on 2/03/2016.
 */
public class Promise<TypeT> {

    //
    //  The current state of the promise.
    //
    public State State;

    //
    //  The result of the promise.
    //
    public TypeT Result;

    //
    //  The reason for a failure.
    //
    public Exception Reason;

    //
    //  Called when the promise is resolved.
    //
    private List<ResolveCallback<TypeT>> resolveCallbacks = new ArrayList<ResolveCallback<TypeT>>();

    //
    //  Called when the promise is rejected.
    //
    private List<RejectCallback> rejectCallbacks = new ArrayList<RejectCallback>();

    public Promise() {

        State = State.Pending;
    }

    //
    //  Sets the promise to resolved and actions registered thenables.
    //
    public void resolve(TypeT result) {

        if (State != State.Pending) {

            return;
        }

        State = State.Resolved;

        Result = result;

        if (resolveCallbacks.size() > 0) {

            for (ResolveCallback callback : resolveCallbacks) {

                callback.onResolved(Result);
            }
        }
    }

    //
    //  Sets the promise to rejected and actions registered catchers.
    //
    public void reject(Exception e) {

        if (State != State.Pending) {

            return;
        }

        State = State.Rejected;

        Reason = e;
    }

    //
    //  Registers a thenable and catcher.
    //
    public void then(ResolveCallback<TypeT> resolveCallback, RejectCallback rejectCallback) {

        if (resolveCallback != null) {

            resolveCallbacks.add(resolveCallback);
        }

        if (rejectCallback != null) {

            rejectCallbacks.add(rejectCallback);
        }
    }

    //
    //  Registers a thenable with the promise.
    //
    public void then(ResolveCallback<TypeT> resolveCallback) {

        if (resolveCallback != null) {

            resolveCallbacks.add(resolveCallback);
        }
    }

}<commit_msg>Converted the comments to the java standard comment.<commit_after>package com.java_promise.genericpromise;

import com.java_promise.common.RejectCallback;
import com.java_promise.common.State;

import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;

/**
 * Created by Philip on 2/03/2016.
 */
public class Promise<TypeT> {

    /**
     * The current state of the promise.
     */
    public State State;

    /**
     * The result of the promise.
     */
    public TypeT Result;

    /**
     * The reason for a failure.
     */
    public Exception Reason;

    /**
     * Called when the promise is resolved.
     */
    private List<ResolveCallback<TypeT>> resolveCallbacks = new ArrayList<>();

    /**
     * Called when the promise is rejected.
     */
    private List<RejectCallback> rejectCallbacks = new ArrayList<>();

    public Promise() {

        State = State.Pending;
    }

    /**
     * Sets the promise to resolved and actions registered thenables.
     * @param result
     */
    public void resolve(TypeT result) {

        if (State != State.Pending) {

            return;
        }

        State = State.Resolved;

        Result = result;

        if (resolveCallbacks.size() > 0) {

            for (ResolveCallback callback : resolveCallbacks) {

                callback.onResolved(Result);
            }
        }
    }

    /**
     * Sets the promise to rejected and actions registered catchers.
     * @param exception
     */
    public void reject(Exception exception) {

        if (State != State.Pending) {

            return;
        }

        State = State.Rejected;

        Reason = exception;
    }

    /**
     * Registers a thenable and catcher.
     * @param resolveCallback
     * @param rejectCallback
     */
    public void then(ResolveCallback<TypeT> resolveCallback, RejectCallback rejectCallback) {

        if (resolveCallback != null) {

            resolveCallbacks.add(resolveCallback);
        }

        if (rejectCallback != null) {

            rejectCallbacks.add(rejectCallback);
        }
    }

    /**
     * Registers a thenable with the promise.
     * @param resolveCallback
     */
    public void then(ResolveCallback<TypeT> resolveCallback) {

        if (resolveCallback != null) {

            resolveCallbacks.add(resolveCallback);
        }
    }
}
{'fraction_non_alphanumeric': 0.10002198285337437, 'fraction_numerical': 0.003517256539898879, 'mean_word_length': 1.9449838187702266, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4552849', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1234, 'n_words': 325}