]> gerrit.simantics Code Review - simantics/interop.git/blobdiff - org.simantics.interop.update/src/org/simantics/interop/update/model/PropertyChange.java
Fix possible NPE when handling added and removed properties
[simantics/interop.git] / org.simantics.interop.update / src / org / simantics / interop / update / model / PropertyChange.java
index 25d43592f7491662b349674d0bc80d5d61ce69a8..69256b0381ed7549ed4f4484734b6ddbbf306fc6 100644 (file)
@@ -16,11 +16,15 @@ public class PropertyChange {
        
        
        public PropertyChange(GraphChanges changes, Statement first, Statement second) {
+               if (first == null && second == null)
+                       throw new IllegalArgumentException("At least one of the stamenents must be non null.");
                this.pair = new Pair<Statement, Statement>(first, second);
                this.changes = changes;
        }
        
        public PropertyChange(GraphChanges changes, Pair<Statement, Statement> change) {
+               if (change == null || (change.first == null && change.second == null))
+                       throw new IllegalArgumentException("At least one of the stamenents must be non null.");
                this.pair = change;
                this.changes = changes;
        }
@@ -96,4 +100,14 @@ public class PropertyChange {
                this.visible = visible;
        }
        
+       @Override
+       public String toString() {
+               String s = "PropertyChange";
+               if (pair.first != null)
+                       s += " (" + (pair.first.getSubject()) + " , " + pair.first.getPredicate() + " , " + pair.first.getObject() + ")";
+               if (pair.second != null)
+                       s += " (" + (pair.second.getSubject()) + " , " + pair.second.getPredicate() + " , " + pair.second.getObject() + ")";
+               return s;
+       }
+       
 }