Skip to content

Commit

Permalink
Fix errors from merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed Sep 6, 2016
1 parent 0679dd7 commit d31dcf4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

package com.microsoft.azure.management.resources.fluentcore.utils;

import com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableImpl;
import com.microsoft.rest.ServiceCallback;
import com.microsoft.rest.ServiceResponse;

/**
* Defines a few utilities.
*/
Expand All @@ -27,59 +23,6 @@ public static boolean toPrimitiveBoolean(Boolean value) {
return value;
}

/**
* Creates a void callback from a callback that returns another type of
* instance. This is useful for internal async handoffs where returned
* resource is stored elsewhere.
*
* @param model the fluent model
* @param callback the callback to return the fluent model
* @param <T> the fluent model type
* @return the void callback
*/
public static <T> ServiceCallback<Void> toVoidCallback(final T model, final ServiceCallback<T> callback) {
return new ServiceCallback<Void>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<Void> result) {
callback.success(new ServiceResponse<>(model, result.getResponse()));
}
};
}

/**
* Creates a callback returning the inner resource from a fluent model
* and a void callback, and set the inner on the fluent model.
*
* @param modelImpl the implementation instance of the fluent resource
* @param callback the void callback
* @param <T> the inner resource type
* @param <FluentT> the fluent resource type
* @param <ResourceT> the fluent model base type that all fluent models in the same task group derive from
* @param <FluentImplT> the implementation for the fluent resource type
*
* @return new callback from the void callback
*/
public static <T, FluentT extends ResourceT, ResourceT, FluentImplT extends CreatableImpl<FluentT, T, FluentImplT>> ServiceCallback<T>
fromVoidCallback(final FluentImplT modelImpl, final ServiceCallback<Void> callback) {
return new ServiceCallback<T>() {
@Override
public void failure(Throwable t) {
callback.failure(t);
}

@Override
public void success(ServiceResponse<T> result) {
modelImpl.setInner(result.getBody());
callback.success(new ServiceResponse<Void>(result.getHeadResponse()));
}
};
}

private Utils() {
}
}
Original file line number Diff line number Diff line change
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

0 comments on commit d31dcf4

Please sign in to comment.