checkstyle: Add EqualsAvoidNull

This commit is contained in:
Daniel Martí 2015-10-08 22:09:51 +02:00
parent 174e37e4e0
commit 3f8875ab9c
8 changed files with 19 additions and 18 deletions

View File

@ -96,7 +96,7 @@ public class CompatibilityChecker extends Compatibility {
if (apk.features != null) {
for (final String feat : apk.features) {
if (ignoreTouchscreen && feat.equals("android.hardware.touchscreen")) {
if (ignoreTouchscreen && "android.hardware.touchscreen".equals(feat)) {
continue;
}
if (!features.contains(feat)) {

View File

@ -137,7 +137,7 @@ public class FDroid extends ActionBarActivity {
appId = data.getQueryParameter("fdid");
} else if (path.startsWith("/app")) {
appId = data.getLastPathSegment();
if (appId != null && appId.equals("app")) {
if ("app".equals(appId)) {
appId = null;
}
}
@ -168,10 +168,10 @@ public class FDroid extends ActionBarActivity {
query = data.getQueryParameter("s");
break;
}
} else if (scheme.equals("fdroid.app")) {
} else if ("fdroid.app".equals(scheme)) {
// fdroid.app:app.id
appId = data.getSchemeSpecificPart();
} else if (scheme.equals("fdroid.search")) {
} else if ("fdroid.search".equals(scheme)) {
// fdroid.search:query
query = data.getSchemeSpecificPart();
}

View File

@ -315,8 +315,8 @@ public class FDroidApp extends Application {
// let's find it
for (ResolveInfo info : pm.queryIntentActivities(sendBt, 0)) {
bluetoothPackageName = info.activityInfo.packageName;
if (bluetoothPackageName.equals("com.android.bluetooth")
|| bluetoothPackageName.equals("com.mediatek.bluetooth")) {
if ("com.android.bluetooth".equals(bluetoothPackageName)
|| "com.mediatek.bluetooth".equals(bluetoothPackageName)) {
className = info.activityInfo.name;
found = true;
break;

View File

@ -88,7 +88,7 @@ public class RepoXMLHandler extends DefaultHandler {
super.endElement(uri, localName, qName);
if (localName.equals("application") && curapp != null) {
if ("application".equals(localName) && curapp != null) {
apps.add(curapp);
curapp = null;
// If the app id is already present in this apps list, then it
@ -99,7 +99,7 @@ public class RepoXMLHandler extends DefaultHandler {
// happen, and I don't *think* it will crash the client, because
// the first app will insert, the second one will update the newly
// inserted one.
} else if (localName.equals("package") && curapk != null && curapp != null) {
} else if ("package".equals(localName) && curapk != null && curapp != null) {
apksList.add(curapk);
curapk = null;
} else if (curchars.length() == 0) {
@ -119,12 +119,12 @@ public class RepoXMLHandler extends DefaultHandler {
curapk.size = Utils.parseInt(str, 0);
break;
case "hash":
if (hashType == null || hashType.equals("md5")) {
if (hashType == null || "md5".equals(hashType)) {
if (curapk.hash == null) {
curapk.hash = str;
curapk.hashType = "MD5";
}
} else if (hashType.equals("sha256")) {
} else if ("sha256".equals(hashType)) {
curapk.hash = str;
curapk.hashType = "SHA-256";
}
@ -227,7 +227,7 @@ public class RepoXMLHandler extends DefaultHandler {
curapp.requirements = Utils.CommaSeparatedList.make(str);
break;
}
} else if (localName.equals("description")) {
} else if ("description".equals(localName)) {
description = cleanWhiteSpace(str);
}
}
@ -237,7 +237,7 @@ public class RepoXMLHandler extends DefaultHandler {
Attributes attributes) throws SAXException {
super.startElement(uri, localName, qName, attributes);
if (localName.equals("repo")) {
if ("repo".equals(localName)) {
signingCertFromIndexXml = attributes.getValue("", "pubkey");
maxage = Utils.parseInt(attributes.getValue("", "maxage"), -1);
version = Utils.parseInt(attributes.getValue("", "version"), -1);
@ -249,16 +249,16 @@ public class RepoXMLHandler extends DefaultHandler {
if (dc != null)
description = cleanWhiteSpace(dc);
} else if (localName.equals("application") && curapp == null) {
} else if ("application".equals(localName) && curapp == null) {
curapp = new App();
curapp.id = attributes.getValue("", "id");
} else if (localName.equals("package") && curapp != null && curapk == null) {
} else if ("package".equals(localName) && curapp != null && curapk == null) {
curapk = new Apk();
curapk.id = curapp.id;
curapk.repo = repo.getId();
hashType = null;
} else if (localName.equals("hash") && curapk != null) {
} else if ("hash".equals(localName) && curapk != null) {
hashType = attributes.getValue("", "type");
}
curchars.setLength(0);

View File

@ -247,7 +247,7 @@ public final class Utils {
XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
int eventType = xml.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && xml.getName().equals("uses-sdk")) {
if (eventType == XmlPullParser.START_TAG && "uses-sdk".equals(xml.getName())) {
for (int j = 0; j < xml.getAttributeCount(); j++) {
if (xml.getAttributeName(j).equals(attrName)) {
return Integer.parseInt(xml.getAttributeValue(j));

View File

@ -74,7 +74,7 @@ public class Response {
public int getFileSize() {
if (headers != null) {
for (Map.Entry<String, String> entry : headers.entrySet()) {
if (entry.getKey().toLowerCase(Locale.ENGLISH).equals("content-length")) {
if ("content-length".equals(entry.getKey().toLowerCase(Locale.ENGLISH))) {
try {
return Integer.parseInt(entry.getValue());
} catch (NumberFormatException e) {

View File

@ -148,7 +148,7 @@ public class WifiQrView extends ScrollView implements SwapWorkflowActivity.Inner
// But it is only available on later Android versions. As such we use URLEncodedUtils instead.
List<NameValuePair> parameters = URLEncodedUtils.parse(URI.create(sharingUri.toString()), "UTF-8");
for (NameValuePair parameter : parameters) {
if (!parameter.getName().equals("ssid")) {
if (!"ssid".equals(parameter.getName())) {
if (first) {
qrUriString += "?";
first = false;

View File

@ -73,6 +73,7 @@
<module name="UpperEll" />
<module name="StringLiteralEquality" />
<module name="EqualsAvoidNull" />
<!--<module name="EqualsHashCode" />-->
</module>