Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Faltermeier2018-06-08 04:44:29 -0400
committerJohannes Faltermeier2018-06-08 04:44:29 -0400
commit46e8a37f65b40a77824424f9f1178c95cce2abd9 (patch)
treee630354a3485773fd9df7541eda4ba180047d5f5
parent19eedfefdbbdf6b985cbd26ab0dda7539fa42147 (diff)
downloadedapt-46e8a37f65b40a77824424f9f1178c95cce2abd9.tar.gz
edapt-46e8a37f65b40a77824424f9f1178c95cce2abd9.tar.xz
edapt-46e8a37f65b40a77824424f9f1178c95cce2abd9.zip
Add example Factory
-rw-r--r--pages/customdatatypes.html31
1 files changed, 31 insertions, 0 deletions
diff --git a/pages/customdatatypes.html b/pages/customdatatypes.html
index 6b60f00..7e459d4 100644
--- a/pages/customdatatypes.html
+++ b/pages/customdatatypes.html
@@ -34,6 +34,37 @@ In order to overcome this issue, Edapt offers the org.eclipse.emf.edapt.factorie
The easiest way to create such a custom factory for usage with Edapt is to subclass EFactoryImpl and to override createFromString(EDataType, String) and convertToString(EDataType, Object) respectively.
Please note that eDataType.getClassifierID() does not necessarily give the same ids in a dynamic instance.
The ids are generated and might vary. So it is not possible to simply copy the existing EFactory-code, but you have to adjust the switch() statements accordingly, e.g by identifying datatypes via the name attribute.
+</p><p>
+<hr/>
+<a>Listing 2</a> - Example Custom Factory
+<pre class="codebox">
+public class LibraryFactoryImpl extends EFactoryImpl {
+
+ @Override
+ public Object createFromString(EDataType eDataType, String initialValue) {
+ switch (eDataType.getName()) {
+ case "MyCustomDataType":
+ return createMyCustomDataTypeFromString(eDataType, initialValue);
+ default:
+ return super.createFromString(eDataType, initialValue);
+ }
+ }
+
+ @Override
+ public String convertToString(EDataType eDataType, Object instanceValue) {
+ switch (eDataType.getName()) {
+ case "MyCustomDataType":
+ return convertMyCustomDataTypeToString(eDataType, instanceValue);
+ default:
+ return super.convertToString(eDataType, instanceValue);
+ }
+ }
+
+ private String convertMyCustomDataTypeToString(EDataType eDataType, Object instanceValue) {/* TODO */return null;}
+ private Object createMyCustomDataTypeFromString(EDataType eDataType, String initialValue) {/* TODO */return null;}
+}
+</pre>
+<hr/>
</p>
</div>
</div> \ No newline at end of file

Back to the top