com.zipwhip.concurrent.DifferentExecutorObserverAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zipwhip-api Show documentation
Show all versions of zipwhip-api Show documentation
Java client to support applications powered by the Zipwhip Cloud
The newest version!
package com.zipwhip.concurrent;
import com.zipwhip.events.Observer;
import com.zipwhip.executors.SimpleExecutor;
import java.util.concurrent.Executor;
/**
* Created with IntelliJ IDEA.
* User: Michael
* Date: 9/8/12
* Time: 11:36 AM
*
* For converting to a different executor.
*/
public class DifferentExecutorObserverAdapter implements Observer {
final Observer observer;
final Executor executor;
public DifferentExecutorObserverAdapter(Observer observer) {
this.executor = SimpleExecutor.getInstance();
this.observer = observer;
}
public DifferentExecutorObserverAdapter(Executor executor, Observer observer) {
this.observer = observer;
if (executor == null){
executor = SimpleExecutor.getInstance();
}
this.executor = executor;
}
@Override
public void notify(final Object sender, final T item) {
executor.execute(new Runnable() {
@Override
public void run() {
observer.notify(sender, item);
}
@Override
public String toString() {
return observer.toString();
}
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy