X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.objmap2%2Fsrc%2Forg%2Fsimantics%2Fobjmap%2Fstructural%2Fannotations%2Ffactories%2FOptionalRelatedElementsRuleFactory.java;h=34066cc169cd34844a3a706af64e038f73f4dab2;hb=4b2ffb1be3b95a8d7b87fc9267e2b3921643a9b3;hp=734b3cd795f89ce398cc82b318fbb3d9e811409a;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java index 734b3cd79..34066cc16 100644 --- a/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/annotations/factories/OptionalRelatedElementsRuleFactory.java +++ b/bundles/org.simantics.objmap2/src/org/simantics/objmap/structural/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.structural.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.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.structural.rules.domain.RelatedObjectsAccessor; -import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; -import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; -import org.simantics.objmap.structural.StructuralResource; - - -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(),false), - 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.structural.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.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.structural.rules.domain.RelatedObjectsAccessor; +import org.simantics.objmap.graph.rules.factory.IFieldRuleFactory; +import org.simantics.objmap.graph.rules.range.FieldAccessorWithDefault; +import org.simantics.objmap.structural.StructuralResource; + + +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(),false), + new FieldAccessorWithDefault>(field, Collections.emptyList()) + ); + } + +}