Refactor: Have only one implementation to resolve parent projects

Often the parent project for a project needs to be resolved. The
parent project can be retrieved from a project by invoking
Project#getParent(). The problem is that this method may return null
for child projects of the wild project. This special case has to be
handled by every caller (if getParent() returns null and it's not the
wild project, the wild project is the parent). Similar code to handle
this situation is repeated in several places.

This change makes one implementation to resolve the parent project
reusable and removes duplicate code.

Change-Id: Id3d8f19c0ea6fc168c2f5dbc15f9e21bc2246d94
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2011-12-28 14:36:06 +01:00
parent 17abbef1b7
commit 128381f984
5 changed files with 32 additions and 41 deletions

View File

@@ -269,10 +269,6 @@ public class ProjectState {
if (isAllProjects) {
return null;
}
Project.NameKey parentName = getProject().getParent();
if (parentName == null) {
parentName = allProjectsName;
}
return projectCache.get(parentName);
return projectCache.get(getProject().getParent(allProjectsName));
}
}