]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/adapter/Adapter.java
Improved Bindings.getBinding(Class) caching for Datatype.class
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / adapter / Adapter.java
1 /*******************************************************************************
2  *  Copyright (c) 2010 Association for Decentralized Information Management in
3  *  Industry THTH ry.
4  *  All rights reserved. This program and the accompanying materials
5  *  are made available under the terms of the Eclipse Public License v1.0
6  *  which accompanies this distribution, and is available at
7  *  http://www.eclipse.org/legal/epl-v10.html
8  *
9  *  Contributors:
10  *      VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.databoard.adapter;
13
14 import org.simantics.databoard.Bindings;
15
16 /**
17  * Adapter converts one java class instance to another.
18  * 
19  * Use {@link Bindings#getAdapter(org.simantics.databoard.binding.Binding, org.simantics.databoard.binding.Binding)}
20  * to instantiate an adapter between bindings.
21  */
22 public interface Adapter {
23
24     /**
25      * Adapt instance of one binding to format of another binding.
26      * 
27      * Note! adapt may recycle the argument (use it in the result).
28      * This dependes on the implementation. Cloning adapter recycles only
29      * immutable instances.
30      * 
31      * @param obj source instance
32      * @return result 
33      * @throws AdaptException 
34      */
35         public abstract Object adapt(Object obj)
36         throws AdaptException;
37         
38     /**
39      * Adapt instance of one binding to format of another binding.
40      * 
41      * Note! adapt may recycle the argument (use it in the result).
42      * This dependes on the implementation. Cloning adapter recycles only
43      * immutable instances.
44      * 
45      * @param obj source instance
46      * @return result 
47      * @throws RuntimeAdaptException 
48      */
49         public abstract Object adaptUnchecked(Object obj)
50         throws RuntimeAdaptException;
51         
52         
53 }
54