Skip to content
Snippets Groups Projects
Commit 43bf53d9 authored by Simon Barner's avatar Simon Barner
Browse files

getLabelForValue():

 - In case the label could not be found, return a string representation of the value. This is useful to implement custom label providers for model elements are edited in combo boxes.
 - Prevent potential NPE
parent 9ea7c8d2
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ import org.fortiss.tooling.kernel.model.IProjectRootElement;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 3CC7BDC51E71BC0EBB1F1DD636CD5BA3
* @ConQAT.Rating YELLOW Hash: 5862DB773F1E83455D589302987C4848
*/
public class LabelValueMapping {
......@@ -185,7 +185,7 @@ public class LabelValueMapping {
/** Translates a value into the corresponding label. */
public String getLabelForValue(Object value) {
if(labelToValueMap == null) {
return value.toString();
return value != null ? value.toString() : "";
}
for(String key : labelToValueMap.keySet()) {
......@@ -196,7 +196,10 @@ public class LabelValueMapping {
}
}
return "";
// In case the label could not be found, return a string representation of the value. This
// is useful to implement custom label providers for model elements are edited in combo
// boxes.
return value != null ? value.toString() : "";
}
/** Translates a label into the corresponding value. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment