]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/binding/factory/SingleBindingScheme.java
Don't recompile all expressions if only one is modified
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / binding / factory / SingleBindingScheme.java
1 /*******************************************************************************
2  * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     VTT Technical Research Centre of Finland - initial API and implementation
10  *******************************************************************************/
11 package org.simantics.databoard.binding.factory;
12
13 import org.simantics.databoard.binding.Binding;
14 import org.simantics.databoard.binding.error.BindingConstructionException;
15 import org.simantics.databoard.binding.error.RuntimeBindingConstructionException;
16 import org.simantics.databoard.type.Datatype;
17
18 public class SingleBindingScheme implements BindingScheme {
19
20         Binding b;
21         
22         public SingleBindingScheme(Binding b) {
23                 this.b = b;
24         }
25
26         @Override
27         public Binding getBinding(Datatype type)
28                         throws BindingConstructionException {
29                 if (type.equals(b.type())) return b;
30                 throw new BindingConstructionException(type+" is not supported");
31         }
32
33         @Override
34         public Binding getBindingUnchecked(Datatype type)
35                         throws RuntimeBindingConstructionException {
36                 if (type.equals(b.type())) return b;
37                 throw new RuntimeBindingConstructionException(new BindingConstructionException(type+" is not supported"));
38         }
39
40         @Override
41         public boolean supportsType(Datatype type) {
42                 return type.equals( b.type() );
43         }
44
45 }
46