]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/src/org/simantics/databoard/adapter/Adapter.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.databoard / src / org / simantics / databoard / adapter / Adapter.java
1 /*******************************************************************************\r
2  *  Copyright (c) 2010 Association for Decentralized Information Management in\r
3  *  Industry THTH ry.\r
4  *  All rights reserved. This program and the accompanying materials\r
5  *  are made available under the terms of the Eclipse Public License v1.0\r
6  *  which accompanies this distribution, and is available at\r
7  *  http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  *  Contributors:\r
10  *      VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.databoard.adapter;
13
14 import org.simantics.databoard.Bindings;\r
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).\r
28      * This dependes on the implementation. Cloning adapter recycles only\r
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;\r
37         \r
38     /**\r
39      * Adapt instance of one binding to format of another binding.\r
40      * \r
41      * Note! adapt may recycle the argument (use it in the result).\r
42      * This dependes on the implementation. Cloning adapter recycles only\r
43      * immutable instances.\r
44      * \r
45      * @param obj source instance\r
46      * @return result \r
47      * @throws RuntimeAdaptException \r
48      */\r
49         public abstract Object adaptUnchecked(Object obj)\r
50         throws RuntimeAdaptException;\r
51         
52         
53 }
54