]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/PrimitiveSpecAttribute.java
Introduce runnable interception
[gpl/argeo-slc.git] / runtime / org.argeo.slc.core / src / main / java / org / argeo / slc / core / execution / PrimitiveSpecAttribute.java
index 27910bf905229eac0b91a5ff55874a5f314c6cd9..0186a1c3cb584be1a04c4eabdf299bed1b425fc8 100644 (file)
@@ -1,5 +1,6 @@
 package org.argeo.slc.core.execution;
 
+import org.argeo.slc.SlcException;
 
 public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
                PrimitiveAccessor {
@@ -29,8 +30,33 @@ public class PrimitiveSpecAttribute extends AbstractSpecAttribute implements
                return type;
        }
 
+       public Class<?> getTypeAsClass() {
+               return typeAsClass(type);
+       }
+
        public void setType(String type) {
                this.type = type;
+
+               // check whether type is recognized.
+               // TODO: make validation cleaner
+               typeAsClass(type);
+       }
+
+       public static Class<?> typeAsClass(String type) {
+               if (TYPE_STRING.equals(type))
+                       return String.class;
+               else if (TYPE_INTEGER.equals(type))
+                       return Integer.class;
+               else if (TYPE_LONG.equals(type))
+                       return Long.class;
+               else if (TYPE_FLOAT.equals(type))
+                       return Float.class;
+               else if (TYPE_DOUBLE.equals(type))
+                       return Double.class;
+               else if (TYPE_BOOLEAN.equals(type))
+                       return Boolean.class;
+               else
+                       throw new SlcException("Unrecognized type " + type);
        }
 
 }