Android Open Source - android-deferred-object Piped Promise






From Project

Back to project page android-deferred-object.

License

The source code is released under:

GNU General Public License

If you think the Android project android-deferred-object listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2012 Cristian Vrabie, Evelina Vrabie
 */*from w  ww  .j  a v a  2  s . c  o  m*/
 * This file is part of android-deferred-object.
 *
 * android-deferred-object is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * android-deferred-object is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.codeandmagic.deferredobject;

import org.codeandmagic.deferredobject.pipe.ProgressFilter;
import org.codeandmagic.deferredobject.pipe.RejectFilter;
import org.codeandmagic.deferredobject.pipe.ResolveFilter;

/** User: cvrabie1 Date: 09/07/2012 */
public class PipedPromise<Resolved1, Rejected1, Progress1, Resolved2, Rejected2, Progress2>
  extends AbstractPromise<Resolved2, Rejected2, Progress2>  {

  protected PipedPromise(final Promise<Resolved1, Rejected1, Progress1> pipedPromise,
                      final ResolveFilter<Resolved1, Resolved2> resolvedFilter,
                      final RejectFilter<Rejected1, Rejected2> rejectedFilter,
                      final ProgressFilter<Progress1, Progress2> progressFilter
  ){
    pipedPromise.done(new ResolveCallback<Resolved1>() {
      @Override
      public void onResolve(Resolved1 resolved1) {
        PipedPromise.this.resolve( resolvedFilter.filterResolved(resolved1) );
      }
    });

    pipedPromise.fail(new RejectCallback<Rejected1>() {
      @Override
      public void onReject(Rejected1 rejected1) {
        PipedPromise.this.reject( rejectedFilter.filterRejected(rejected1) );
      }
    });

    pipedPromise.progress(new ProgressCallback<Progress1>() {
      @Override
      public void onProgress(Progress1 progress1) {
        PipedPromise.this.notify(progressFilter.filterProgress(progress1));
      }
    });
  }
}




Java Source Code List

org.codeandmagic.deferredobject.AbstractPromise.java
org.codeandmagic.deferredobject.CompleteCallback.java
org.codeandmagic.deferredobject.DeferredObject.java
org.codeandmagic.deferredobject.MainActivity.java
org.codeandmagic.deferredobject.MergedPromiseTracker.java
org.codeandmagic.deferredobject.PipedPromise.java
org.codeandmagic.deferredobject.ProgressCallback.java
org.codeandmagic.deferredobject.PromiseProxy.java
org.codeandmagic.deferredobject.Promise.java
org.codeandmagic.deferredobject.RejectCallback.java
org.codeandmagic.deferredobject.ResolveCallback.java
org.codeandmagic.deferredobject.android.DeferredAsyncTask.java
org.codeandmagic.deferredobject.android.DeferredHttpUrlConnection.java
org.codeandmagic.deferredobject.android.HttpProgress.java
org.codeandmagic.deferredobject.merge.MergedPromise2.java
org.codeandmagic.deferredobject.merge.MergedPromise3.java
org.codeandmagic.deferredobject.merge.MergedPromise4.java
org.codeandmagic.deferredobject.merge.MergedPromise5.java
org.codeandmagic.deferredobject.merge.MergedPromiseN.java
org.codeandmagic.deferredobject.merge.MergedPromiseProgress.java
org.codeandmagic.deferredobject.merge.MergedPromiseReject.java
org.codeandmagic.deferredobject.merge.MergedPromiseResult2.java
org.codeandmagic.deferredobject.merge.MergedPromiseResult3.java
org.codeandmagic.deferredobject.merge.MergedPromiseResult4.java
org.codeandmagic.deferredobject.merge.MergedPromiseResult5.java
org.codeandmagic.deferredobject.merge.MergedPromise.java
org.codeandmagic.deferredobject.pipe.PassThroughProgressFilter.java
org.codeandmagic.deferredobject.pipe.PassThroughRejectFilter.java
org.codeandmagic.deferredobject.pipe.PassThroughResolveFilter.java
org.codeandmagic.deferredobject.pipe.ProgressFilter.java
org.codeandmagic.deferredobject.pipe.RejectFilter.java
org.codeandmagic.deferredobject.pipe.ResolveFilter.java
org.codeandmagic.deferredobject.pipe.ResolvePipe.java