]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/g3d/property/DefaultPropertyManipulatorFactory.java
Copyrights
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / property / DefaultPropertyManipulatorFactory.java
1 /*******************************************************************************\r
2  * Copyright (c) 2012, 2013 Association for Decentralized Information Management in\r
3  * Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g3d.property;\r
13 \r
14 import java.lang.reflect.Method;\r
15 \r
16 import javax.vecmath.Quat4d;\r
17 import javax.vecmath.Vector3d;\r
18 \r
19 public class DefaultPropertyManipulatorFactory implements PropertyManipulatorFactory {\r
20         \r
21         @Override\r
22         public Class<? extends PropertyManipulator> get(Method get, Object value) {\r
23                 Class<?> returnValue = null;\r
24                 if (get != null)\r
25                         returnValue = get.getReturnType();\r
26                 else\r
27                         returnValue = value.getClass();\r
28                 if (Double.class.equals(returnValue))\r
29                         return DoublePropertyManipulator.class;\r
30                 if (Vector3d.class.equals(returnValue))\r
31                         return VectorPropertyManipulator.class;\r
32                 if (Quat4d.class.equals(returnValue))\r
33                         return QuatPropertyManipulator.class;\r
34                 if (String.class.equals(returnValue))\r
35                         return StringPropertyManipulator.class;\r
36                 if (Integer.class.equals(returnValue))\r
37                         return IntegerPropertyManipulator.class;\r
38                 if (Boolean.class.equals(returnValue))\r
39                         return BooleanPropertyManipulator.class;\r
40                 if(double.class.equals(returnValue)) \r
41                         return DoublePropertyManipulator.class;\r
42                 if(int.class.equals(returnValue))\r
43                         return IntegerPropertyManipulator.class;\r
44                 if(boolean.class.equals(returnValue))\r
45                         return BooleanPropertyManipulator.class;\r
46                 throw new RuntimeException("Cannot handle value " + returnValue.getName() + " for method " + get);\r
47         }\r
48 \r
49 }\r