]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/Adapter.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / Adapter.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/Adapter.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/Adapter.java
new file mode 100644 (file)
index 0000000..3f5e502
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************\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.g2d.element.handler;\r
+\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.ElementUtils;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+\r
+/**\r
+ * This handler makes it possible to add adapters to different objects into an\r
+ * {@link ElementClass}. An element can have multiple Adapter handlers. For\r
+ * adaption, they are processed in the order of definition within the\r
+ * {@link ElementClass} and adaption should return the first\r
+ * <code>non-null</code> result returned by the any Adapter implementation.\r
+ * \r
+ * <p>\r
+ * See {@link ElementUtils#adapt(org.simantics.g2d.element.IElement, Class)} for\r
+ * a utility that implements the above logic.\r
+ * </p>\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ * @see StaticObjectAdapter\r
+ */\r
+public interface Adapter extends ElementHandler {\r
+\r
+    /**\r
+     * @return\r
+     */\r
+    <T> T adapt(Class<T> toClass);\r
+\r
+}
\ No newline at end of file