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