package com.microsoft.azure.arm.model.implementation;
import com.microsoft.azure.arm.model.Refreshable;
import rx.Observable;
import rx.functions.Func1;
public abstract class RefreshableWrapperImpl<InnerT, Impl>
extends WrapperImpl<InnerT>
implements Refreshable<Impl> {
protected RefreshableWrapperImpl(InnerT innerObject) {
super(innerObject);
}
@Override
public final Impl refresh() {
return this.refreshAsync().toBlocking().last();
}
@Override
public Observable<Impl> refreshAsync() {
final RefreshableWrapperImpl<InnerT, Impl> self = this;
return this.getInnerAsync().map(new Func1<InnerT, Impl>() {
@Override
public Impl call(InnerT innerT) {
self.setInner(innerT);
return (Impl) self;
}
});
}
protected abstract Observable<InnerT> getInnerAsync();
}