]> gerrit.simantics Code Review - simantics/3d.git/blob - org.simantics.g3d/src/org/simantics/g3d/property/MethodComboValueProvider.java
c1e21e071d6ed0d5e7b9c5895b0179fca7377c97
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / property / MethodComboValueProvider.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 import java.util.List;
16
17 public class MethodComboValueProvider implements ComboValueProvider {
18
19         Method getter; 
20         Method setter;
21         Method values;
22         
23         public MethodComboValueProvider(Method getter, Method setter, Method values) {
24                 this.getter = getter;
25                 this.setter = setter;
26                 this.values = values;
27         }
28         
29         @Override
30         public Object getValue(Object obj) throws Exception{
31                 return getter.invoke(obj);
32         }
33         @Override
34         public void setValue(Object obj, Object value) throws Exception {
35                 setter.invoke(obj,value);
36         }
37         
38         public List<Object> getValues(Object obj) throws Exception {
39             return (List<Object>)values.invoke(obj);
40         }
41 }