1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.adaption;
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;
20 public interface AdaptionService {
22 <T,C> T adapt(ReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible) throws DatabaseException;
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);
27 <T> void declareAdapter(Resource type, Class<T> targetClass);
28 <T> void declareAdapter(Resource type, Class<T> targetClass, Class<?> contextClass);
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);
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);
37 * Remove instance adapter to specified class for specified resource,
38 * regardless of the currently installed adapter.
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
46 <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz);
47 <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz, Class<?> contextClass);
50 * Remove instance adapter to specified class for specified resource
51 * if the currently installed adapter matches the specified adapter.
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
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);