Code readability and null check.
@@ -120,19 +120,24 @@ public class PURLPackage {
String extraInfo = null;
- if (type.equals("deb")) {
+ switch (type) {
+ case "deb":
pp.setType(Constants.debianForge);
pp.setNamespace(temp[1]);
extraInfo = temp[2];
- } else if (type.equals("maven")) {
+ break;
+ case "maven":
pp.setType(Constants.mvnForge);
pp.setNamespace(temp[1]);
extraInfo = temp[2];
- } else if(type.equals("pypi")) {
+ break;
+ case "pypi":
pp.setType(Constants.pypiForge);
extraInfo = temp[1];
+ break;
}
+ if(extraInfo != null) {
// Parse extra info
String[] infoFirst = extraInfo.split("@");
pp.setName(infoFirst[0]);
@@ -148,6 +153,7 @@ public class PURLPackage {
pp.getQualifiers().put(res[0], res[1]);
}
}
+ }
return pp;
}
