@Override public int compareTo(Application otherApp) { int nameCompare = name.compareTo(otherApp.getName()); if (nameCompare == 0) { return version.compareTo(otherApp.getVersion()); } else { return nameCompare; } }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!(obj instanceof Application)) { return false; } Application otherApp = (Application) obj; return name.equals(otherApp.getName()) && version.equals(otherApp.getVersion()); }
private Map<String, Object> convertApplicationNode(ApplicationNode application) { LOGGER.debug("Converting {} to a map", application.getApplication().getName()); Map<String, Object> appMap = new HashMap<String, Object>(); Application internalApplication = application.getApplication(); appMap.put(MAP_NAME, internalApplication.getName()); appMap.put(MAP_VERSION, internalApplication.getVersion()); appMap.put(MAP_DESCRIPTION, internalApplication.getDescription()); appMap.put(MAP_STATE, application.getStatus().getState().toString()); appMap.put(MAP_URI, internalApplication.getURI().toString()); List<Map<String, Object>> children = new ArrayList<Map<String, Object>>(); for (ApplicationNode curNode : application.getChildren()) { children.add(convertApplicationNode(curNode)); } appMap.put(MAP_CHILDREN, children); return appMap; }
private Map<String, Object> convertApplicationEntries( ApplicationNode application, List<String> parentList, List<Map<String, Object>> applicationsArray) { LOGGER.debug("Converting {} to a map", application.getApplication().getName()); Map<String, Object> appMap = new HashMap<String, Object>(); Application internalApplication = application.getApplication(); appMap.put(MAP_NAME, internalApplication.getName()); appMap.put(MAP_VERSION, internalApplication.getVersion()); appMap.put(MAP_DESCRIPTION, internalApplication.getDescription()); appMap.put(MAP_STATE, application.getStatus().getState().toString()); appMap.put(MAP_URI, internalApplication.getURI().toString()); List<String> childrenList = new ArrayList<String>(); parentList.add(internalApplication.getName()); List<String> transferParentList = new ArrayList<String>(); appMap.put(MAP_PARENTS, parentList); for (ApplicationNode curNode : application.getChildren()) { Application node = curNode.getApplication(); childrenList.add(node.getName()); makeDependencyList(childrenList, curNode); convertApplicationEntries(curNode, parentList, applicationsArray); } appMap.put(MAP_DEPENDENCIES, childrenList); if (parentList.size() == 1) { transferParentList.clear(); appMap.put(MAP_PARENTS, transferParentList); } else { int index = parentList.indexOf(internalApplication.getName()); for (int i = 0; i < index; i++) { transferParentList.add(parentList.get(i)); } appMap.put(MAP_PARENTS, transferParentList); parentList.clear(); parentList.addAll(transferParentList); } applicationsArray.add(appMap); return appMap; }