--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.adaption;\r
+\r
+import org.simantics.db.AsyncReadGraph;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.procedure.AsyncProcedure;\r
+\r
+public interface AdaptionService {\r
+\r
+ <T,C> T adapt(ReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible) throws DatabaseException;\r
+ \r
+ <T,C> void adapt(AsyncReadGraph g, Resource r, C context, Class<C> contextClass, Class<T> targetClass, boolean possible, AsyncProcedure<T> procedure);\r
+ <T> void adaptNew(AsyncReadGraph g, Resource r, Class<T> clazz, boolean possible, AsyncProcedure<T> procedure);\r
+\r
+ <T> void declareAdapter(Resource type, Class<T> targetClass);\r
+ <T> void declareAdapter(Resource type, Class<T> targetClass, Class<?> contextClass);\r
+\r
+ <T> void addAdapter(Resource type, Class<T> targetClass, Adapter<T, ?> adapter);\r
+ <T> void addAdapter(Resource type, Class<T> targetClass, Class<?> contextClass, Adapter<T, ?> adapter);\r
+ \r
+ <T> void addInstanceAdapter(Resource resource, Class<T> targetClass, Adapter<T, ?> adapter);\r
+ <T> void addInstanceAdapter(Resource resource, Class<T> targetClass, Class<?> contextClass, Adapter<T, ?> adapter);\r
+\r
+ /**\r
+ * Remove instance adapter to specified class for specified resource,\r
+ * regardless of the currently installed adapter.\r
+ * \r
+ * @param <T> the adaptation target type\r
+ * @param resource the resource from which to remove the adapter\r
+ * @param clazz the target class of the adapter to be removed\r
+ * @return the removed adapter or <code>null</code> if no adapter was\r
+ * installed\r
+ */\r
+ <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz);\r
+ <T> Adapter<T,?> removeInstanceAdapter(Resource resource, Class<T> clazz, Class<?> contextClass);\r
+\r
+ /**\r
+ * Remove instance adapter to specified class for specified resource\r
+ * if the currently installed adapter matches the specified adapter.\r
+ * \r
+ * @param <T> the adaptation target type\r
+ * @param resource the resource from which to remove the adapter\r
+ * @param clazz the target class of the adapter to be removed\r
+ * @param adapter the adapter to remove\r
+ */\r
+ <T> void removeInstanceAdapter(Resource resource, Class<T> clazz, Adapter<T,?> adapter);\r
+ <T> void removeInstanceAdapter(Resource resource, Class<T> clazz, Class<?> contextClass, Adapter<T,?> adapter);\r
+\r
+}\r