Skip to content

Commit 345d9c4

Browse files
committed
Fixed diamond operators
1 parent c514d29 commit 345d9c4

File tree

7 files changed

+27
-19
lines changed

7 files changed

+27
-19
lines changed

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

+14-6
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ public AsyncHttpClient(SchemeRegistry schemeRegistry) {
218218
ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(httpParams, schemeRegistry);
219219

220220
threadPool = Executors.newCachedThreadPool();
221-
requestMap = new WeakHashMap();
222-
clientHeaderMap = new HashMap();
221+
requestMap = new WeakHashMap<>();
222+
clientHeaderMap = new HashMap<>();
223223

224224
httpContext = new SyncBasicHttpContext(new BasicHttpContext());
225225
httpClient = new DefaultHttpClient(cm, httpParams);
@@ -978,9 +978,17 @@ public RequestHandle delete(Context context, String url, Header[] headers, Reque
978978
* @return RequestHandle of future request process
979979
*/
980980
protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, ResponseHandlerInterface responseHandler, Context context) {
981-
if (responseHandler != null && responseHandler.getUseSynchronousMode()) {
982-
throw new IllegalArgumentException("Synchronous ResponseHandler used in AsyncHttpClient. You should create your response handler in a looper thread or use SyncHttpClient instead.");
983-
}
981+
if (uriRequest == null) {
982+
throw new IllegalArgumentException("HttpUriRequest must not be null");
983+
}
984+
985+
if (responseHandler == null) {
986+
throw new IllegalArgumentException("ResponseHandler must not be null");
987+
}
988+
989+
if (responseHandler.getUseSynchronousMode()) {
990+
throw new IllegalArgumentException("Synchronous ResponseHandler used in AsyncHttpClient. You should create your response handler in a looper thread or use SyncHttpClient instead.");
991+
}
984992

985993
if (contentType != null) {
986994
uriRequest.setHeader("Content-Type", contentType);
@@ -997,7 +1005,7 @@ protected RequestHandle sendRequest(DefaultHttpClient client, HttpContext httpCo
9971005
// Add request to request map
9981006
List<RequestHandle> requestList = requestMap.get(context);
9991007
if (requestList == null) {
1000-
requestList = new LinkedList();
1008+
requestList = new LinkedList<>();
10011009
requestMap.put(context, requestList);
10021010
}
10031011

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class JsonStreamerEntity implements HttpEntity {
7171
new BasicHeader("Content-Encoding", "gzip");
7272

7373
// JSON data and associated meta-data to be uploaded.
74-
private final Map<String, Object> jsonParams = new HashMap();
74+
private final Map<String, Object> jsonParams = new HashMap<>();
7575

7676
// Whether to use gzip compression while uploading
7777
private final Header contentEncoding;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public class PersistentCookieStore implements CookieStore {
6060
*/
6161
public PersistentCookieStore(Context context) {
6262
cookiePrefs = context.getSharedPreferences(COOKIE_PREFS, 0);
63-
cookies = new ConcurrentHashMap();
63+
cookies = new ConcurrentHashMap<>();
6464

6565
// Load any previously stored cookies into the store
6666
String storedCookieNames = cookiePrefs.getString(COOKIE_NAME_STORE, null);
@@ -146,7 +146,7 @@ public boolean clearExpired(Date date) {
146146

147147
@Override
148148
public List<Cookie> getCookies() {
149-
return new ArrayList(cookies.values());
149+
return new ArrayList<>(cookies.values());
150150
}
151151

152152
/**

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class RequestHandle {
99
private final WeakReference<AsyncHttpRequest> request;
1010

1111
public RequestHandle(AsyncHttpRequest request) {
12-
this.request = new WeakReference(request);
12+
this.request = new WeakReference<>(request);
1313
}
1414

1515
/**

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ public class RequestParams {
9696
protected boolean isRepeatable;
9797
protected boolean useJsonStreamer;
9898
protected boolean autoCloseInputStreams;
99-
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap();
100-
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap();
101-
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap();
102-
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap();
99+
protected final ConcurrentHashMap<String, String> urlParams = new ConcurrentHashMap<>();
100+
protected final ConcurrentHashMap<String, StreamWrapper> streamParams = new ConcurrentHashMap<>();
101+
protected final ConcurrentHashMap<String, FileWrapper> fileParams = new ConcurrentHashMap<>();
102+
protected final ConcurrentHashMap<String, Object> urlParamsWithObjects = new ConcurrentHashMap<>();
103103
protected String contentEncoding = HTTP.UTF_8;
104104

105105
/**
@@ -483,7 +483,7 @@ private HttpEntity createMultipartEntity(ResponseHandlerInterface progressHandle
483483
}
484484

485485
protected List<BasicNameValuePair> getParamsList() {
486-
List<BasicNameValuePair> lparams = new LinkedList();
486+
List<BasicNameValuePair> lparams = new LinkedList<>();
487487

488488
for (ConcurrentHashMap.Entry<String, String> entry : urlParams.entrySet()) {
489489
lparams.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
@@ -495,7 +495,7 @@ protected List<BasicNameValuePair> getParamsList() {
495495
}
496496

497497
private List<BasicNameValuePair> getParamsList(String key, Object value) {
498-
List<BasicNameValuePair> params = new LinkedList();
498+
List<BasicNameValuePair> params = new LinkedList<>();
499499
if (value instanceof Map) {
500500
Map map = (Map) value;
501501
List list = new ArrayList<Object>(map.keySet());

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import javax.net.ssl.SSLException;
4141

4242
class RetryHandler implements HttpRequestRetryHandler {
43-
private final static HashSet<Class<?>> exceptionWhitelist = new HashSet();
44-
private final static HashSet<Class<?>> exceptionBlacklist = new HashSet();
43+
private final static HashSet<Class<?>> exceptionWhitelist = new HashSet<>();
44+
private final static HashSet<Class<?>> exceptionBlacklist = new HashSet<>();
4545

4646
static {
4747
// Retry if the server dropped connection on us

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class SimpleMultipartEntity implements HttpEntity {
5959
private final byte[] boundaryEnd;
6060
private boolean isRepeatable;
6161

62-
private final List<FilePart> fileParts = new ArrayList();
62+
private final List<FilePart> fileParts = new ArrayList<>();
6363

6464
// The buffer we use for building the message excluding files and the last
6565
// boundary

0 commit comments

Comments
 (0)