1 package org.simantics.g3d.objmap.annotations.factories;
\r
3 import java.lang.annotation.Annotation;
\r
4 import java.lang.reflect.Method;
\r
6 import org.simantics.db.ReadGraph;
\r
7 import org.simantics.db.exception.DatabaseException;
\r
8 import org.simantics.g3d.objmap.annotations.RelatedGetObj;
\r
9 import org.simantics.g3d.objmap.annotations.RelatedGetValue;
\r
10 import org.simantics.g3d.objmap.annotations.RelatedSetObj;
\r
11 import org.simantics.g3d.objmap.annotations.RelatedSetValue;
\r
12 import org.simantics.g3d.objmap.rules.factory.IGetSetRuleFactory;
\r
13 import org.simantics.g3d.objmap.rules.range.GetSetObjectAccessor;
\r
14 import org.simantics.objmap.IMappingRule;
\r
15 import org.simantics.objmap.rules.MappedElementRule;
\r
16 import org.simantics.objmap.rules.domain.RelatedObjectAccessor;
\r
19 * Rule factory for mapped object using Getter/Setter-methods.
\r
21 * @author Marko Luukkainen <marko.luukkainen@vtt.fi>
\r
24 public class RelatedGetSetObjRuleFactory implements IGetSetRuleFactory {
\r
27 public IMappingRule create(ReadGraph g, Annotation annotation,
\r
28 Method getter, Method setter)
\r
29 throws DatabaseException {
\r
30 RelatedGetObj getterAnn = (RelatedGetObj)annotation;
\r
31 return new MappedElementRule(new RelatedObjectAccessor(g.getResource(getterAnn.value())),
\r
32 new GetSetObjectAccessor<Object>(getter, setter));
\r
36 public boolean isSetter(Annotation getterAnnotation, Annotation annotation) {
\r
37 RelatedGetObj getterAnn = (RelatedGetObj)getterAnnotation;
\r
38 RelatedSetObj setterAnn = (RelatedSetObj)annotation;
\r
39 return getterAnn.value().equals(setterAnn.value());
\r