X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.objmap2%2Fsrc%2Forg%2Fsimantics%2Fobjmap%2Fgraph%2Fannotations%2Ffactories%2FOptionalRelatedElementsRuleFactory.java;h=08ed10b686de6400c66f1237b171eba2712039f5;hb=87d3c60a5c520cca584c54e6bc0fd8c9576141a7;hp=84b1134ac01f9cec9cbdd7c65a16c47bcecb05ac;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java index 84b1134ac..08ed10b68 100644 --- a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java +++ b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/annotations/factories/OptionalRelatedElementsRuleFactory.java @@ -1,44 +1,44 @@ -/******************************************************************************* - * Copyright (c) 2007, 2013 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.objmap.graph.annotations.factories; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.util.Collection; -import java.util.Collections; - -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.ResourceNotFoundException; -import org.simantics.db.exception.ServiceException; -import org.simantics.db.exception.ValidationException; -import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; -import org.simantics.objmap.graph.annotations.OptionalRelatedElements; -import org.simantics.objmap.graph.rules.MappedElementsRule; -import org.simantics.objmap.graph.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; - - -public class OptionalRelatedElementsRuleFactory implements IFieldRuleFactory { - - @Override - public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - OptionalRelatedElements annotation = (OptionalRelatedElements)_annotation; - return new MappedElementsRule( - new RelatedObjectsAccessor(g.getResource(annotation.value()), - annotation.composition()), - new FieldAccessorWithDefault>(field, Collections.emptyList()) - ); - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2013 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.objmap.graph.annotations.factories; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Collections; + +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.ResourceNotFoundException; +import org.simantics.db.exception.ServiceException; +import org.simantics.db.exception.ValidationException; +import org.simantics.objmap.bidirectional.IBidirectionalMappingRule; +import org.simantics.objmap.graph.annotations.OptionalRelatedElements; +import org.simantics.objmap.graph.rules.MappedElementsRule; +import org.simantics.objmap.graph.rules.domain.RelatedObjectsAccessor; +import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; +import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; + + +public class OptionalRelatedElementsRuleFactory implements IFieldRuleFactory { + + @Override + public IBidirectionalMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { + OptionalRelatedElements annotation = (OptionalRelatedElements)_annotation; + return new MappedElementsRule( + new RelatedObjectsAccessor(g.getResource(annotation.value()), + annotation.composition()), + new FieldAccessorWithDefault>(field, Collections.emptyList()) + ); + } + +}