]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db/src/org/simantics/db/adaption/AdaptionService.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / adaption / AdaptionService.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
3  * in 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.db.adaption;\r
13 \r
14 import org.simantics.db.AsyncReadGraph;\r
15 import org.simantics.db.ReadGraph;\r
16 import org.simantics.db.Resource;\r
17 import org.simantics.db.exception.DatabaseException;\r
18 import org.simantics.db.procedure.AsyncProcedure;\r
19 \r
20 public interface AdaptionService {\r
21 \r
22         <T,C> T adapt(ReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible) throws DatabaseException;\r
23         \r
24     <T,C> void adapt(AsyncReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible, AsyncProcedure<T> procedure);\r
25     <T> void adaptNew(AsyncReadGraph g, Resource r, Class<T> clazz, boolean possible, AsyncProcedure<T> procedure);\r
26 \r
27     <T> void declareAdapter(Resource type, Class<T> targetClass);\r
28     <T> void declareAdapter(Resource type, Class<T> targetClass, Class<?> contextClass);\r
29 \r
30     <T> void addAdapter(Resource type, Class<T> targetClass, Adapter<T, ?> adapter);\r
31     <T> void addAdapter(Resource type, Class<T> targetClass, Class<?> contextClass, Adapter<T, ?> adapter);\r
32     \r
33     <T> void addInstanceAdapter(Resource resource, Class<T> targetClass, Adapter<T, ?> adapter);\r
34     <T> void addInstanceAdapter(Resource resource, Class<T> targetClass, Class<?> contextClass, Adapter<T, ?> adapter);\r
35 \r
36     /**\r
37      * Remove instance adapter to specified class for specified resource,\r
38      * regardless of the currently installed adapter.\r
39      * \r
40      * @param <T> the adaptation target type\r
41      * @param resource the resource from which to remove the adapter\r
42      * @param clazz the target class of the adapter to be removed\r
43      * @return the removed adapter or <code>null</code> if no adapter was\r
44      *         installed\r
45      */\r
46     <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz);\r
47     <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz, Class<?> contextClass);\r
48 \r
49     /**\r
50      * Remove instance adapter to specified class for specified resource\r
51      * if the currently installed adapter matches the specified adapter.\r
52      * \r
53      * @param <T> the adaptation target type\r
54      * @param resource the resource from which to remove the adapter\r
55      * @param clazz the target class of the adapter to be removed\r
56      * @param adapter the adapter to remove\r
57      */\r
58     <T> void removeInstanceAdapter(Resource resource, Class<T> clazz, Adapter<T,?> adapter);\r
59     <T> void removeInstanceAdapter(Resource resource, Class<T> clazz, Class<?> contextClass, Adapter<T,?> adapter);\r
60 \r
61 }\r