public DebugTarget(@NotNull Debuggee debuggee, @NotNull String projectName) { myDebuggee = debuggee; if (myDebuggee.getLabels() != null) { myDescription = ""; myModule = ""; myVersion = ""; String minorVersion = ""; // Get the module name, major version and minor version strings. for (Map.Entry<String, String> entry : myDebuggee.getLabels().entrySet()) { if (entry.getKey().equalsIgnoreCase(MODULE)) { myModule = entry.getValue(); } else if (entry.getKey().equalsIgnoreCase("minorversion")) { minorVersion = entry.getValue(); } else if (entry.getKey().equalsIgnoreCase("version")) { myVersion = entry.getValue(); } else { // This is fallback logic where we dump the labels verbatim if they // change from underneath us. myDescription += String.format("%s:%s", entry.getKey(), entry.getValue()); } } // Build a description from the strings. if (!Strings.isNullOrEmpty(myModule)) { myDescription = GctBundle.getString("clouddebug.version.with.module.format", myModule, myVersion); } else if (!Strings.isNullOrEmpty(myVersion)) { myDescription = GctBundle.getString("clouddebug.versionformat", myVersion); } // Record the minor version. We only show the latest minor version. try { if (!Strings.isNullOrEmpty(minorVersion)) { myMinorVersion = Long.parseLong(minorVersion); } } catch (NumberFormatException ex) { LOG.warn("unable to parse minor version: " + minorVersion); } } // Finally if nothing worked (maybe labels aren't enabled?), we fall // back to the old logic of using description with the project name stripped out. if (Strings.isNullOrEmpty(myDescription)) { myDescription = myDebuggee.getDescription(); if (myDescription != null && !Strings.isNullOrEmpty(projectName) && myDescription.startsWith(projectName + "-")) { myDescription = myDescription.substring(projectName.length() + 1); } } }
public String getId() { return myDebuggee.getId(); }