Skip to content

Commit 23dbea6

Browse files
committed
Fixed first part of generic warnings
1 parent dfb5947 commit 23dbea6

File tree

1 file changed

+17
-24
lines changed

1 file changed

+17
-24
lines changed

library/src/main/java/com/loopj/android/http/RequestParams.java

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ public class RequestParams {
9393
protected final static String LOG_TAG = "RequestParams";
9494
protected boolean isRepeatable;
9595
protected boolean useJsonStreamer;
96-
protected ConcurrentHashMap<String, String> urlParams;
97-
protected ConcurrentHashMap<String, StreamWrapper> streamParams;
98-
protected ConcurrentHashMap<String, FileWrapper> fileParams;
99-
protected ConcurrentHashMap<String, Object> urlParamsWithObjects;
96+
protected ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<String, String>();
97+
protected ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<String, StreamWrapper>();
98+
protected ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<String, FileWrapper>();
99+
protected ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
100100
protected String contentEncoding = HTTP.UTF_8;
101101

102102
/**
@@ -126,7 +126,6 @@ public RequestParams() {
126126
* @param source the source key/value string map to add.
127127
*/
128128
public RequestParams(Map<String, String> source) {
129-
init();
130129
if (source != null) {
131130
for (Map.Entry<String, String> entry : source.entrySet()) {
132131
put(entry.getKey(), entry.getValue());
@@ -156,7 +155,6 @@ public RequestParams(final String key, final String value) {
156155
* @throws IllegalArgumentException if the number of arguments isn't even.
157156
*/
158157
public RequestParams(Object... keysAndValues) {
159-
init();
160158
int len = keysAndValues.length;
161159
if (len % 2 != 0)
162160
throw new IllegalArgumentException("Supplied arguments must be even");
@@ -293,9 +291,9 @@ public void add(String key, String value) {
293291
this.put(key, params);
294292
}
295293
if (params instanceof List) {
296-
((List<Object>) params).add(value);
294+
((List) params).add(value);
297295
} else if (params instanceof Set) {
298-
((Set<Object>) params).add(value);
296+
((Set) params).add(value);
299297
}
300298
}
301299
}
@@ -459,13 +457,6 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
459457
return entity;
460458
}
461459

462-
private void init() {
463-
urlParams = new ConcurrentHashMap<String, String>();
464-
streamParams = new ConcurrentHashMap<String, StreamWrapper>();
465-
fileParams = new ConcurrentHashMap<String, FileWrapper>();
466-
urlParamsWithObjects = new ConcurrentHashMap<String, Object>();
467-
}
468-
469460
protected List<BasicNameValuePair> getParamsList() {
470461
List<BasicNameValuePair> lparams = new LinkedList<BasicNameValuePair>();
471462

@@ -481,19 +472,21 @@ protected List<BasicNameValuePair> getParamsList() {
481472
private List<BasicNameValuePair> getParamsList(String key, Object value) {
482473
List<BasicNameValuePair> params = new LinkedList<BasicNameValuePair>();
483474
if (value instanceof Map) {
484-
Map<String, Object> map = (Map<String, Object>) value;
485-
List<String> list = new ArrayList<String>(map.keySet());
475+
Map map = (Map) value;
476+
List list = new ArrayList<Object>(map.keySet());
486477
// Ensure consistent ordering in query string
487478
Collections.sort(list);
488-
for (String nestedKey : list) {
489-
Object nestedValue = map.get(nestedKey);
490-
if (nestedValue != null) {
491-
params.addAll(getParamsList(key == null ? nestedKey : String.format("%s[%s]", key, nestedKey),
492-
nestedValue));
479+
for (Object nestedKey : list) {
480+
if (nestedKey instanceof String) {
481+
Object nestedValue = map.get(nestedKey);
482+
if (nestedValue != null) {
483+
params.addAll(getParamsList(key == null ? (String) nestedKey : String.format("%s[%s]", key, nestedKey),
484+
nestedValue));
485+
}
493486
}
494487
}
495488
} else if (value instanceof List) {
496-
List<Object> list = (List<Object>) value;
489+
List list = (List) value;
497490
for (Object nestedValue : list) {
498491
params.addAll(getParamsList(String.format("%s[]", key), nestedValue));
499492
}
@@ -503,7 +496,7 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
503496
params.addAll(getParamsList(String.format("%s[]", key), nestedValue));
504497
}
505498
} else if (value instanceof Set) {
506-
Set<Object> set = (Set<Object>) value;
499+
Set set = (Set) value;
507500
for (Object nestedValue : set) {
508501
params.addAll(getParamsList(key, nestedValue));
509502
}

0 commit comments

Comments
 (0)