Mercurial > hg > thermostat-tools-eclipse
changeset 109:cba7b8de5f76
Preserve class invariants after marshalling
The violation of the invariant (commands and extensions being non-null)
causes NullPointerExceptions when data is being read by the UI. This
causes the relevant tab to not show up at all.
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Thu, 27 Feb 2014 17:00:33 -0500 |
parents | fde496a78a98 |
children | 93f5d040235d |
files | com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java |
diffstat | 1 files changed, 10 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java Thu Feb 27 15:40:52 2014 -0500 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java Thu Feb 27 17:00:33 2014 -0500 @@ -115,6 +115,16 @@ } } + /** After marshalling empty list as no-element, recreate empty list so invariants still hold */ + void afterMarshal(Marshaller marshaller) { + if (this.commands == null) { + this.commands = new ArrayList<>(); + } + if (this.extensions == null) { + this.extensions = new ArrayList<>(); + } + } + /** If null elements were read, re-initialize to empty list */ void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { if (this.commands == null) {