1 /*******************************************************************************
2 * Copyright (c) 2012, 2013 Association for Decentralized Information Management in
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.g3d.property;
14 import java.lang.reflect.Method;
16 import javax.vecmath.Quat4d;
17 import javax.vecmath.Vector3d;
19 public class DefaultPropertyManipulatorFactory implements PropertyManipulatorFactory {
22 public Class<? extends PropertyManipulator> get(Method get, Object value) {
23 Class<?> returnValue = null;
25 returnValue = get.getReturnType();
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 if (returnValue.isEnum())
49 return ComboPropertyManipulator.class;
50 throw new RuntimeException("Cannot handle value " + returnValue.getName() + " for method " + get);