Skip to content

Commit

Permalink
Merge pull request Azure#1060 from jianghaolu/unwrap
Browse files Browse the repository at this point in the history
Remove ServiceResponse<> wrappers in most methods
  • Loading branch information
Martin Sawicki authored Sep 7, 2016
2 parents 0a85d84 + 9be12ef commit ffab45d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void onNext(ServiceResponse<Page<E>> serviceResponse) {
}
}
if (behavior == ListOperationCallback.PagingBehavior.STOP || serviceResponse.getBody().getNextPageLink() == null) {
serviceCall.set(new ServiceResponse<>(lastResponse.getBody().getItems(), lastResponse.getResponse()));
serviceCall.set(lastResponse.getBody().getItems());
} else {
serviceCall.setSubscription(next.call(serviceResponse.getBody().getNextPageLink()).single().subscribe(this));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package com.microsoft.azure;

import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;

import java.util.List;

Expand Down Expand Up @@ -71,7 +70,7 @@ public void load(List<E> result) {
}

@Override
public void success(ServiceResponse<List<E>> result) {
public void success(List<E> result) {
success();
}

Expand Down
14 changes: 7 additions & 7 deletions client-runtime/src/main/java/com/microsoft/rest/ServiceCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @param <T> the type of the returning object
*/
public class ServiceCall<T> extends AbstractFuture<ServiceResponse<T>> {
public class ServiceCall<T> extends AbstractFuture<T> {
/**
* The Retrofit method invocation.
*/
Expand All @@ -42,7 +42,7 @@ public static <T> ServiceCall<T> create(final Observable<ServiceResponse<T>> obs
.subscribe(new Action1<ServiceResponse<T>>() {
@Override
public void call(ServiceResponse<T> t) {
serviceCall.set(t);
serviceCall.set(t.getBody());
}
}, new Action1<Throwable>() {
@Override
Expand All @@ -69,9 +69,9 @@ public static <T> ServiceCall<T> create(final Observable<ServiceResponse<T>> obs
@Override
public void call(ServiceResponse<T> t) {
if (callback != null) {
callback.success(t);
callback.success(t.getBody());
}
serviceCall.set(t);
serviceCall.set(t.getBody());
}
}, new Action1<Throwable>() {
@Override
Expand Down Expand Up @@ -102,9 +102,9 @@ public static <T, V> ServiceCall<T> createWithHeaders(final Observable<ServiceRe
@Override
public void call(ServiceResponse<T> t) {
if (callback != null) {
callback.success(t);
callback.success(t.getBody());
}
serviceCall.set(t);
serviceCall.set(t.getBody());
}
}, new Action1<Throwable>() {
@Override
Expand Down Expand Up @@ -136,7 +136,7 @@ protected void setSubscription(Subscription subscription) {
* @param result the service response returned.
* @return true if successfully reported; false otherwise.
*/
public boolean success(ServiceResponse<T> result) {
public boolean success(T result) {
return set(result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class ServiceCallback<T> {
/**
* Override this method to handle successful REST call results.
*
* @param result the ServiceResponse holding the response.
* @param result the result object.
*/
public abstract void success(ServiceResponse<T> result);
public abstract void success(T result);
}

0 comments on commit ffab45d

Please sign in to comment.