summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2017-01-10 14:46:27 +0000
committerMichael Wright <michaelwr@google.com>2017-01-10 15:05:16 +0000
commitbd097c98fff4ad8c2a3dc8367b580dfdd0702c77 (patch)
tree6bb3e22cffa7b9fba5490c4c72f6bd8e9007d55e
parentc47bc17e47578595a00065686959ca1c7304038c (diff)
downloadloganalysis-bd097c98fff4ad8c2a3dc8367b580dfdd0702c77.tar.gz
Fix a few warnings produced by java lint.
Add a hashCode implementation to GenericItem and LogcatParser.ExtrasPattern, and suppress the warning for the lack of serialVersionUID to the anonymous subclass of HashMap since it'll never actually be serialized. Test: java -cp loganalysis.jar:loganalysis-tests.jar org.junit.runner.JUnitCore com.android.loganalysis.UnitTests Change-Id: Ibbbcaf6d1629cd5cfad172fe0eb6a720525ec483
-rw-r--r--src/com/android/loganalysis/item/DvmLockSampleItem.java3
-rw-r--r--src/com/android/loganalysis/item/GenericItem.java15
-rw-r--r--src/com/android/loganalysis/parser/LogcatParser.java10
3 files changed, 23 insertions, 5 deletions
diff --git a/src/com/android/loganalysis/item/DvmLockSampleItem.java b/src/com/android/loganalysis/item/DvmLockSampleItem.java
index fa3e7a8..d7e9773 100644
--- a/src/com/android/loganalysis/item/DvmLockSampleItem.java
+++ b/src/com/android/loganalysis/item/DvmLockSampleItem.java
@@ -15,8 +15,6 @@
*/
package com.android.loganalysis.item;
-import org.json.JSONException;
-import org.json.JSONObject;
import java.util.Arrays;
import java.util.HashMap;
@@ -44,6 +42,7 @@ public class DvmLockSampleItem extends GenericItem {
WAITING_SOURCE_FILE, WAITING_SOURCE_LINE, OWNER_FILE_NAME,
OWNER_ACQUIRE_SOURCE_LINE, SAMPLE_PERCENTAGE));
+ @SuppressWarnings("serial")
private static final Map<String, Class<?>> TYPES = new HashMap<String, Class<?>>() {{
put(PROCESS_NAME, String.class);
put(SENSITIVITY_FLAG, Boolean.class);
diff --git a/src/com/android/loganalysis/item/GenericItem.java b/src/com/android/loganalysis/item/GenericItem.java
index 0ebf870..b93b658 100644
--- a/src/com/android/loganalysis/item/GenericItem.java
+++ b/src/com/android/loganalysis/item/GenericItem.java
@@ -86,9 +86,7 @@ public class GenericItem implements IItem {
return mergedAttributes;
}
- /**
- * {@inhertiDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isConsistent(IItem other) {
if (this == other) {
@@ -128,6 +126,17 @@ public class GenericItem implements IItem {
return true;
}
+ /** {@inheritDoc} */
+ @Override
+ public int hashCode() {
+ int result = 13;
+ for (String attribute : mAllowedAttributes) {
+ Object val = getAttribute(attribute);
+ result += 37 * (val == null ? 0 : val.hashCode());
+ }
+ return result;
+ }
+
/**
* {@inheritDoc}
* <p>
diff --git a/src/com/android/loganalysis/parser/LogcatParser.java b/src/com/android/loganalysis/parser/LogcatParser.java
index ae3cf62..96cd1c2 100644
--- a/src/com/android/loganalysis/parser/LogcatParser.java
+++ b/src/com/android/loganalysis/parser/LogcatParser.java
@@ -498,6 +498,16 @@ public class LogcatParser implements IParser {
}
return false;
}
+
+ /** {@inheritdoc} */
+ @Override
+ public int hashCode() {
+ // Since both mLevel and mTag can be wild cards, we can't actually use them to generate
+ // a hashcode without potentially violating the hashcode contract. That doesn't leave
+ // us with anything to actually use to generate the hashcode, so just return a random
+ // static int.
+ return 145800969;
+ }
}
/**