X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fprotocol%2FSerializedVariable.java;fp=bundles%2Forg.simantics.structural.synchronization%2Fsrc%2Forg%2Fsimantics%2Fstructural%2Fsynchronization%2Fprotocol%2FSerializedVariable.java;h=73c839b8682f890c83b667b6933aaf6ba5691397;hp=f1888e1012fac8a314fa0329f59b70e3551a05b3;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SerializedVariable.java b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SerializedVariable.java index f1888e101..73c839b86 100644 --- a/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SerializedVariable.java +++ b/bundles/org.simantics.structural.synchronization/src/org/simantics/structural/synchronization/protocol/SerializedVariable.java @@ -1,68 +1,68 @@ -package org.simantics.structural.synchronization.protocol; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.simantics.databoard.binding.mutable.Variant; - -public class SerializedVariable { - - private Map children; - private Map properties; - final public Variant value; - final public String name; - - public SerializedVariable(String name, Variant value) { - this.name = name; - this.value = value; - } - - @SuppressWarnings("unchecked") - public T getPossiblePropertyValue(String name) { - if(properties == null) return null; - SerializedVariable p = properties.get(name); - if(p == null) return null; - else return (T)p.value.getValue(); - } - - @SuppressWarnings("unchecked") - public T getPropertyValue(String name) { - if(properties == null) throw new AssertionError("Property '" + name + "' does not exist."); - SerializedVariable p = properties.get(name); - if(p == null) throw new AssertionError("Property '" + name + "' does not exist."); - else return (T)p.value.getValue(); - } - - public Collection getProperties(){ - if(properties == null) return Collections.emptyList(); - return properties.values(); - } - - public static String print(SerializedVariable var, int indent) { - StringBuilder b = new StringBuilder(); - b.append(var.name + " " + var.value.getValue()); - if(var.children != null) { - for(Map.Entry child : var.children.entrySet()) { - b.append("\n"); - for(int i=0;i property : var.properties.entrySet()) { - b.append("\n"); - for(int i=0;i(); - properties.put(name, property); - } - -} +package org.simantics.structural.synchronization.protocol; + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.simantics.databoard.binding.mutable.Variant; + +public class SerializedVariable { + + private Map children; + private Map properties; + final public Variant value; + final public String name; + + public SerializedVariable(String name, Variant value) { + this.name = name; + this.value = value; + } + + @SuppressWarnings("unchecked") + public T getPossiblePropertyValue(String name) { + if(properties == null) return null; + SerializedVariable p = properties.get(name); + if(p == null) return null; + else return (T)p.value.getValue(); + } + + @SuppressWarnings("unchecked") + public T getPropertyValue(String name) { + if(properties == null) throw new AssertionError("Property '" + name + "' does not exist."); + SerializedVariable p = properties.get(name); + if(p == null) throw new AssertionError("Property '" + name + "' does not exist."); + else return (T)p.value.getValue(); + } + + public Collection getProperties(){ + if(properties == null) return Collections.emptyList(); + return properties.values(); + } + + public static String print(SerializedVariable var, int indent) { + StringBuilder b = new StringBuilder(); + b.append(var.name + " " + var.value.getValue()); + if(var.children != null) { + for(Map.Entry child : var.children.entrySet()) { + b.append("\n"); + for(int i=0;i property : var.properties.entrySet()) { + b.append("\n"); + for(int i=0;i(); + properties.put(name, property); + } + +}