]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.databoard/src/org/simantics/databoard/type/OptionalType.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / type / OptionalType.java
index d704e86b36012468a2d2c4329b22a17b84c7e504..6a69316b82cb19f268bf93850be4521e990f9d12 100644 (file)
@@ -1,26 +1,26 @@
-/*******************************************************************************\r
- *  Copyright (c) 2010 Association for Decentralized Information Management in\r
- *  Industry THTH ry.\r
- *  All rights reserved. This program and the accompanying materials\r
- *  are made available under the terms of the Eclipse Public License v1.0\r
- *  which accompanies this distribution, and is available at\r
- *  http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- *  Contributors:\r
- *      VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
+/*******************************************************************************
+ *  Copyright (c) 2010 Association for Decentralized Information Management in
+ *  Industry THTH ry.
+ *  All rights reserved. This program and the accompanying materials
+ *  are made available under the terms of the Eclipse Public License v1.0
+ *  which accompanies this distribution, and is available at
+ *  http://www.eclipse.org/legal/epl-v10.html
+ *
+ *  Contributors:
+ *      VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
 package org.simantics.databoard.type;
 
-import java.util.Set;\r
-\r
-import org.simantics.databoard.accessor.error.ReferenceException;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.accessor.reference.ComponentReference;\r
-import org.simantics.databoard.accessor.reference.IndexReference;\r
-import org.simantics.databoard.accessor.reference.KeyReference;\r
-import org.simantics.databoard.accessor.reference.LabelReference;\r
-import org.simantics.databoard.accessor.reference.NameReference;\r
-import org.simantics.databoard.util.IdentityPair;\r
+import java.util.Set;
+
+import org.simantics.databoard.accessor.error.ReferenceException;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.accessor.reference.ComponentReference;
+import org.simantics.databoard.accessor.reference.IndexReference;
+import org.simantics.databoard.accessor.reference.KeyReference;
+import org.simantics.databoard.accessor.reference.LabelReference;
+import org.simantics.databoard.accessor.reference.NameReference;
+import org.simantics.databoard.util.IdentityPair;
 
 public class OptionalType extends Datatype {
     public Datatype componentType;
@@ -34,27 +34,27 @@ public class OptionalType extends Datatype {
     
     public Datatype getComponentType() {
        return componentType;
-    }\r
-    \r
-    @Override\r
-    public int getComponentCount() {\r
-       return 1;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(int index) {\r
-       if (index!=0) throw new IllegalArgumentException();\r
-       return componentType;\r
-    }\r
-    \r
-    @Override\r
-    public Datatype getComponentType(ChildReference path) {\r
-       if (path==null) return this;\r
-       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in OptionalType"); \r
-       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in OptionalType"); \r
-       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");\r
-       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");\r
-       return componentType.getComponentType(path.childReference);\r
+    }
+    
+    @Override
+    public int getComponentCount() {
+       return 1;
+    }
+    
+    @Override
+    public Datatype getComponentType(int index) {
+       if (index!=0) throw new IllegalArgumentException();
+       return componentType;
+    }
+    
+    @Override
+    public Datatype getComponentType(ChildReference path) {
+       if (path==null) return this;
+       if (path instanceof KeyReference) throw new IllegalArgumentException("KeyReference is not supported in OptionalType"); 
+       if (path instanceof NameReference) throw new IllegalArgumentException("NameReference is not supported in OptionalType"); 
+       if (path instanceof IndexReference && ((IndexReference) path).index!=0) throw new IllegalArgumentException("Index out of bounds");
+       if (path instanceof LabelReference && !((LabelReference) path).label.equals("v")) throw new IllegalArgumentException("Unknown label");
+       return componentType.getComponentType(path.childReference);
     }    
     
        @Override
@@ -63,16 +63,16 @@ public class OptionalType extends Datatype {
                componentType.collectSubtypes(subtypes, recursiveSubtypes);
        }
     
-    @Override\r
-    public int hashCode() {\r
-       return componentType.hashCode() + metadataHashCode();\r
-    }\r
-    \r
+    @Override
+    public int hashCode() {
+       return componentType.hashCode() + metadataHashCode();
+    }
+    
     @Override
     protected boolean deepEquals(Object obj, Set<IdentityPair<Datatype, Datatype>> compareHistory) {
-               if (this==obj) return true;\r
-               if (obj instanceof OptionalType == false) return false;\r
-               if ( !hasEqualMetadata(obj) ) return false;\r
+               if (this==obj) return true;
+               if (obj instanceof OptionalType == false) return false;
+               if ( !hasEqualMetadata(obj) ) return false;
                OptionalType other = (OptionalType) obj;
                return componentType.deepEquals(other.componentType, compareHistory);
     }     
@@ -86,24 +86,24 @@ public class OptionalType extends Datatype {
        public <T> T accept(Visitor<T> v) {
            return v.visit(this);
        }       
-\r
-       @SuppressWarnings("unchecked")\r
-       @Override\r
-       public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {\r
-               if (reference==null) return (T) this;\r
-\r
-               if (reference instanceof LabelReference) {\r
-                       LabelReference lr = (LabelReference) reference;\r
-                       if (lr.label.equals("o")) {\r
-                               return componentType.getChildType(reference.getChildReference());\r
-                       }                       \r
-               }\r
-               \r
-               if (reference instanceof ComponentReference) {\r
-                       return componentType.getChildType(reference.getChildReference());\r
-               } \r
-               \r
-               throw new ReferenceException(reference.getClass()+" is not a reference of OptionalType");               \r
-       }\r
+
+       @SuppressWarnings("unchecked")
+       @Override
+       public <T extends Datatype> T getChildType(ChildReference reference) throws ReferenceException {
+               if (reference==null) return (T) this;
+
+               if (reference instanceof LabelReference) {
+                       LabelReference lr = (LabelReference) reference;
+                       if (lr.label.equals("o")) {
+                               return componentType.getChildType(reference.getChildReference());
+                       }                       
+               }
+               
+               if (reference instanceof ComponentReference) {
+                       return componentType.getChildType(reference.getChildReference());
+               } 
+               
+               throw new ReferenceException(reference.getClass()+" is not a reference of OptionalType");               
+       }
        
 }