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