X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.objmap2%2Fsrc%2Forg%2Fsimantics%2Fobjmap%2Fgraph%2Frules%2Frange%2FFieldAccessorWithDefault.java;fp=bundles%2Forg.simantics.objmap2%2Fsrc%2Forg%2Fsimantics%2Fobjmap%2Fgraph%2Frules%2Frange%2FFieldAccessorWithDefault.java;h=48b7bfb8f84f4710e3cabebecbf4b04d69667af9;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hp=dea8cf353d10bd022187e34b981f206378df90b2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java index dea8cf353..48b7bfb8f 100644 --- a/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java +++ b/bundles/org.simantics.objmap2/src/org/simantics/objmap/graph/rules/range/FieldAccessorWithDefault.java @@ -1,40 +1,40 @@ -/******************************************************************************* - * 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.rules.range; - -import java.lang.reflect.Field; - -import org.simantics.objmap.exceptions.MappingException; - - -/** - * Accesses the given field of the element. - * @author Hannu Niemist� - */ -public class FieldAccessorWithDefault extends FieldAccessor { - - T defaultValue; - - public FieldAccessorWithDefault(Field field, T defaultValue) { - super(field); - this.defaultValue = defaultValue; - } - - @Override - public T get(Range element) throws MappingException { - T value = super.get(element); - if(value == null) - return defaultValue; - else - return value; - } -} +/******************************************************************************* + * 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.rules.range; + +import java.lang.reflect.Field; + +import org.simantics.objmap.exceptions.MappingException; + + +/** + * Accesses the given field of the element. + * @author Hannu Niemist� + */ +public class FieldAccessorWithDefault extends FieldAccessor { + + T defaultValue; + + public FieldAccessorWithDefault(Field field, T defaultValue) { + super(field); + this.defaultValue = defaultValue; + } + + @Override + public T get(Range element) throws MappingException { + T value = super.get(element); + if(value == null) + return defaultValue; + else + return value; + } +}