diff --git a/app-java/src/main/java/ly/count/java/demo/BackendModeExample.java b/app-java/src/main/java/ly/count/java/demo/BackendModeExample.java index 0946cba6..cbd375ed 100644 --- a/app-java/src/main/java/ly/count/java/demo/BackendModeExample.java +++ b/app-java/src/main/java/ly/count/java/demo/BackendModeExample.java @@ -312,7 +312,7 @@ public static void main(String[] args) throws Exception { String[] sdkStorageRootPath = { System.getProperty("user.home"), "__COUNTLY", "java_test" }; File sdkStorageRootDirectory = new File(String.join(File.separator, sdkStorageRootPath)); - if ((!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory())) && !sdkStorageRootDirectory.mkdirs()) { + if (!(sdkStorageRootDirectory.exists() && sdkStorageRootDirectory.isDirectory()) && !sdkStorageRootDirectory.mkdirs()) { DemoUtils.println("Directory creation failed"); } diff --git a/app-java/src/main/java/ly/count/java/demo/BackendModePerformanceTests.java b/app-java/src/main/java/ly/count/java/demo/BackendModePerformanceTests.java index dc2c4931..8085a695 100644 --- a/app-java/src/main/java/ly/count/java/demo/BackendModePerformanceTests.java +++ b/app-java/src/main/java/ly/count/java/demo/BackendModePerformanceTests.java @@ -199,13 +199,13 @@ public static void main(String[] args) throws Exception { case 2: performLargeEventQueueTest(); running = false; - DemoUtils.printf("Time spent: %dms%n", (System.currentTimeMillis() - startTime)); + DemoUtils.printf("Time spent: %dms%n", System.currentTimeMillis() - startTime); break; case 3: startTime = System.currentTimeMillis(); recordBulkDataAndSendToServer(); running = false; - DemoUtils.printf("Time spent: %dms%n", (System.currentTimeMillis() - startTime)); + DemoUtils.printf("Time spent: %dms%n", System.currentTimeMillis() - startTime); break; default: break; diff --git a/sdk-java/src/main/java/ly/count/sdk/java/Config.java b/sdk-java/src/main/java/ly/count/sdk/java/Config.java index 63739bd1..0bee67fc 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/Config.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/Config.java @@ -138,7 +138,7 @@ public boolean equals(Object obj) { return false; } DID did = (DID) obj; - return did.strategy == strategy && (Objects.equals(did.id, id)); + return did.strategy == strategy && Objects.equals(did.id, id); } @Override @@ -379,7 +379,7 @@ public Config disableUnhandledCrashReporting() { this.unhandledCrashReportingEnabled = false; return this; } - + protected String location = null; protected String ip = null; protected String city = null; diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/EventImpl.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/EventImpl.java index 239c52b8..43c53e89 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/EventImpl.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/EventImpl.java @@ -219,13 +219,13 @@ public boolean equals(Object obj) { if (count != event.count) { return false; } - if ((sum != null && !sum.equals(event.sum) || (event.sum != null && !event.sum.equals(sum)))) { + if (sum != null && !sum.equals(event.sum) || (event.sum != null && !event.sum.equals(sum))) { return false; } - if ((duration != null && !duration.equals(event.duration) || (event.duration != null && !event.duration.equals(duration)))) { + if (duration != null && !duration.equals(event.duration) || (event.duration != null && !event.duration.equals(duration))) { return false; } - if ((segmentation != null && !segmentation.equals(event.segmentation) || (event.segmentation != null && !event.segmentation.equals(segmentation)))) { + if (segmentation != null && !segmentation.equals(event.segmentation) || (event.segmentation != null && !event.segmentation.equals(segmentation))) { return false; } return true; diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleBackendMode.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleBackendMode.java index c20e0fda..53bac5a7 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleBackendMode.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleBackendMode.java @@ -334,13 +334,12 @@ protected Map removeInvalidDataFromSegments(Map for (Map.Entry item : segments.entrySet()) { Object type = item.getValue(); - boolean isValidDataType = (type instanceof Boolean + boolean isValidDataType = type instanceof Boolean || type instanceof Integer || type instanceof Long || type instanceof String || type instanceof Double - || type instanceof Float - ); + || type instanceof Float; if (!isValidDataType) { toRemove.add(item.getKey()); diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleEvents.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleEvents.java index 6ca2564a..b4a6c771 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleEvents.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleEvents.java @@ -44,12 +44,12 @@ public void deviceIdChanged(String oldDeviceId, boolean withMerge) { // this part is to end and record the current view if exists Session session = Countly.session(); - if ((session != null && session.isActive())) { + if (session != null && session.isActive()) { View currentView = ((SessionImpl) session).currentView; if (currentView != null) { currentView.stop(true); } else { - Storage.pushAsync(internalConfig, ((SessionImpl) Countly.session())); + Storage.pushAsync(internalConfig, (SessionImpl) Countly.session()); } } @@ -126,7 +126,7 @@ private void addEventToQueue(EventImpl event) { private void checkEventQueueToSend(boolean forceSend) { L.d("[ModuleEvents] queue size:[" + eventQueue.eqSize() + "] || forceSend: " + forceSend); - if (forceSend || (eventQueue.eqSize() >= internalConfig.getEventsBufferSize())) { + if (forceSend || eventQueue.eqSize() >= internalConfig.getEventsBufferSize()) { addEventsToRequestQ(null); } } diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleLocation.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleLocation.java index ebde7f77..c81b2adb 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleLocation.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleLocation.java @@ -47,7 +47,7 @@ void sendLocation() { void setLocationInternal(@Nullable String countryCode, @Nullable String cityName, @Nullable String gpsCoordinates, @Nullable String ipAddress) { L.d("[ModuleLocation] setLocationInternal, Setting location parameters, cc[" + countryCode + "] cy[" + city + "] gps[" + gpsCoordinates + "] ip[" + ipAddress + "]"); - if ((countryCode == null && city != null) || (city == null && countryCode != null)) { + if (countryCode != null ^ city != null) { L.w("[ModuleLocation] setLocationInternal, both city and country code need to be set at the same time to be sent"); } country = countryCode; diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleUserProfile.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleUserProfile.java index 72cd09a5..9d592aa2 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleUserProfile.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/ModuleUserProfile.java @@ -56,7 +56,7 @@ enum Op { object.put("$max", Math.max(object.optDouble("$max", (Double) value), (Double) value)); json.put(key, object); }), - SET_ONCE(((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).put("$setOnce", value)))), + SET_ONCE((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).put("$setOnce", value))), PULL((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$pull", value))), PUSH((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$push", value))), PUSH_UNIQUE((json, key, value) -> json.put(key, json.optJSONObject(key, new JSONObject()).accumulate("$addToSet", value))); diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/Params.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/Params.java index 7ed453e7..5fd95ec1 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/Params.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/Params.java @@ -91,12 +91,12 @@ public Params add() { public Params(Object... objects) { params = new StringBuilder(); - if (objects != null && objects.length == 1 && (objects[0] instanceof Object[])) { + if (objects != null && objects.length == 1 && objects[0] instanceof Object[]) { addObjects((Object[]) objects[0]); - } else if (objects != null && objects.length == 1 && (objects[0] instanceof Params)) { - params.append(objects[0].toString()); - } else if (objects != null && objects.length == 1 && (objects[0] instanceof String)) { - params.append(objects[0].toString()); + } else if (objects != null && objects.length == 1 && objects[0] instanceof Params) { + params.append(objects[0]); + } else if (objects != null && objects.length == 1 && objects[0] instanceof String) { + params.append(objects[0]); } else { addObjects(objects); } @@ -276,7 +276,7 @@ private Params addObjects(Object[] objects) { L.e("Bad number of parameters"); } else { for (int i = 0; i < objects.length; i += 2) { - add(objects[i] == null ? ("unknown" + i) : objects[i].toString(), objects.length > i + 1 ? objects[i + 1] : null); + add(objects[i] == null ? "unknown" + i : objects[i].toString(), objects.length > i + 1 ? objects[i + 1] : null); } } return this; diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/SessionImpl.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/SessionImpl.java index 715f9c43..a964a84c 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/SessionImpl.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/SessionImpl.java @@ -612,13 +612,13 @@ public boolean equals(Object obj) { if (!id.equals(session.id)) { return false; } - if ((began != null && !began.equals(session.began) || (session.began != null && !session.began.equals(began)))) { + if (began != null && !began.equals(session.began) || (session.began != null && !session.began.equals(began))) { return false; } - if ((updated != null && !updated.equals(session.updated) || (session.updated != null && !session.updated.equals(updated)))) { + if (updated != null && !updated.equals(session.updated) || (session.updated != null && !session.updated.equals(updated))) { return false; } - if ((ended != null && !ended.equals(session.ended) || (session.ended != null && !session.ended.equals(ended)))) { + if (ended != null && !ended.equals(session.ended) || (session.ended != null && !session.ended.equals(ended))) { return false; } if (!params.equals(session.params)) { diff --git a/sdk-java/src/main/java/ly/count/sdk/java/internal/UserEditorImpl.java b/sdk-java/src/main/java/ly/count/sdk/java/internal/UserEditorImpl.java index 4d988eaa..33e586cc 100644 --- a/sdk-java/src/main/java/ly/count/sdk/java/internal/UserEditorImpl.java +++ b/sdk-java/src/main/java/ly/count/sdk/java/internal/UserEditorImpl.java @@ -72,7 +72,7 @@ public UserEditor setPicture(byte[] picture) { @Override public UserEditor setPicturePath(String picturePath) { L.d("[UserEditorImpl] setPicturePath, picturePath = " + picturePath); - if (picturePath == null || Utils.isValidURL(picturePath) || (new File(picturePath)).isFile()) { + if (picturePath == null || Utils.isValidURL(picturePath) || new File(picturePath).isFile()) { //if it is a thing we can use, continue return set(PredefinedUserPropertyKeys.PICTURE_PATH, picturePath); } diff --git a/sdk-java/src/test/java/ly/count/sdk/java/internal/MigrationHelperTests.java b/sdk-java/src/test/java/ly/count/sdk/java/internal/MigrationHelperTests.java index 1a7cd790..6487cb4f 100644 --- a/sdk-java/src/test/java/ly/count/sdk/java/internal/MigrationHelperTests.java +++ b/sdk-java/src/test/java/ly/count/sdk/java/internal/MigrationHelperTests.java @@ -72,7 +72,7 @@ public void beforeTest() { private void initStorage() { InternalConfig config = (new InternalConfig(TestUtils.getBaseConfig())); config.setLogger(mock(Log.class)); - storageProvider = (new SDKStorage()).init(config); + storageProvider = new SDKStorage().init(config); } /** diff --git a/sdk-java/src/test/java/ly/count/sdk/java/internal/SdkStorageTests.java b/sdk-java/src/test/java/ly/count/sdk/java/internal/SdkStorageTests.java index ae32cbfc..0b9da835 100644 --- a/sdk-java/src/test/java/ly/count/sdk/java/internal/SdkStorageTests.java +++ b/sdk-java/src/test/java/ly/count/sdk/java/internal/SdkStorageTests.java @@ -30,7 +30,7 @@ public void stop() { //doing all of this just to stop the Task //todo eliminate this InternalConfig config = TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig()); - SDKStorage storageProvider = (new SDKStorage()).init(config); + SDKStorage storageProvider = new SDKStorage().init(config); storageProvider.stop(config, true); } @@ -41,7 +41,7 @@ public void stop() { */ @Test public void getDeviceID() { - SDKStorage storageProvider = (new SDKStorage()).init(TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig())); + SDKStorage storageProvider = new SDKStorage().init(TestUtils.getInternalConfigWithLogger(TestUtils.getBaseConfig())); Assert.assertNull(storageProvider.getDeviceID()); } diff --git a/sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java b/sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java index 72456e20..ba5eb841 100644 --- a/sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java +++ b/sdk-java/src/test/java/ly/count/sdk/java/internal/SessionImplTests.java @@ -531,8 +531,8 @@ public void equals_notInstanceOf() { */ @Test public void equals_differentId() { - validateNotEquals(1, ((session, session2) -> ts -> { - })); + validateNotEquals(1, (session, session2) -> ts -> { + }); } /**