Use meaningful parameter name in ParseSearchResultFromJson and ParseSearchDatabagFromJson.

Also use static import for Sets and Iterables.
This commit is contained in:
Noorul Islam K M 2013-09-18 14:09:18 +05:30 committed by Ignasi Barrera
parent f8c0659988
commit 18a3b77edb
4 changed files with 14 additions and 13 deletions

View File

@ -26,7 +26,7 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import static com.google.common.collect.Iterables.getFirst;
/**
* Parses the cookbook versions in a Chef Server <= 0.9.8.
@ -44,8 +44,8 @@ public class ParseCookbookVersionsV09FromJson implements Function<HttpResponse,
}
@Override
public Set<String> apply(HttpResponse arg0) {
return Iterables.getFirst(json.apply(arg0).values(), null);
public Set<String> apply(HttpResponse response) {
return getFirst(json.apply(response).values(), null);
}
}

View File

@ -28,8 +28,9 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import static com.google.common.collect.Iterables.getFirst;
import static com.google.common.collect.Iterables.transform;
import static com.google.common.collect.Sets.newLinkedHashSet;
/**
* Parses the cookbook versions in a Chef Server >= 0.10.8.
@ -49,8 +50,8 @@ public class ParseCookbookVersionsV10FromJson implements Function<HttpResponse,
@Override
public Set<String> apply(HttpResponse response) {
CookbookDefinition def = Iterables.getFirst(parser.apply(response).values(), null);
return Sets.newLinkedHashSet(Iterables.transform(def.getVersions(), new Function<Version, String>() {
CookbookDefinition def = getFirst(parser.apply(response).values(), null);
return newLinkedHashSet(transform(def.getVersions(), new Function<Version, String>() {
@Override
public String apply(Version input) {
return input.getVersion();

View File

@ -29,8 +29,8 @@ import org.jclouds.http.functions.ParseJson;
import org.jclouds.json.Json;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.gson.annotations.SerializedName;
import static com.google.common.collect.Iterables.transform;
/**
* Parses the search result into a {@link DatabagItem} object.
@ -64,9 +64,9 @@ public class ParseSearchDatabagFromJson implements Function<HttpResponse, Search
}
@Override
public SearchResult<DatabagItem> apply(HttpResponse arg0) {
Response returnVal = responseParser.apply(arg0);
Iterable<DatabagItem> items = Iterables.transform(returnVal.rows, new Function<Row, DatabagItem>() {
public SearchResult<DatabagItem> apply(HttpResponse response) {
Response returnVal = responseParser.apply(response);
Iterable<DatabagItem> items = transform(returnVal.rows, new Function<Row, DatabagItem>() {
@Override
public DatabagItem apply(Row input) {
return json.fromJson(input.rawData.toString(), DatabagItem.class);

View File

@ -46,8 +46,8 @@ public class ParseSearchResultFromJson<T> implements Function<HttpResponse, Sear
}
@Override
public SearchResult<T> apply(HttpResponse arg0) {
Response<T> returnVal = json.apply(arg0);
public SearchResult<T> apply(HttpResponse response) {
Response<T> returnVal = json.apply(response);
return new SearchResult<T>(returnVal.start, returnVal.rows);
}
}