Add a new Data Type¶
Important
This section requires some knowledge about Eclipse Extension Points.
What is a data type?¶
A data type is a language that can be used to specify the format of a data. The term data represents both inputs and outputs. Concretely, a datatype is a parser that can:
- Instantiate an
Object
from a given String - Create a String from an existing
Object
.
It is hence responsible of serializing and deserializing data so that they can both be persisted and used during the execution.
How to add a new datatype?¶
A new one can be defined by contributing to the fr.kazejiyu.ekumi.core.datatypes
extension point.
It requires one class that implements the DataType<T>
interface.
The interface is defined as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | public interface DataType<T> {
/**
* Returns an identifier for this type.
* @return an identifier for this type.
*/
String getId();
/**
* Returns the name of the type.
* @return the name of the type.
*/
String getName();
/**
* Returns the Java class corresponding to this type.
* @return the Java class corresponding to this type.
*/
Class<T> getJavaClass();
/**
* Returns the default value of a new instance of this type.
* @return the default value of a new instance of this type.
*/
T getDefaultValue();
/**
* Returns a String representation of the type.<br>
* <br>
* For any type {@code type}, the following assertion must be {@code true}:
* <pre>{@code instance.equals( type.unserialize(type.serialize(instance)) );}</pre>
*
* @return a String representation of the type.
*
* @throws DataTypeSerializationException if T cannot be turned into a String
*
* @see #unserialize(String)
*/
String serialize(T instance);
/**
* Returns a new instance of the type from a given representation.<br>
* <br>
* For any type {@code type}, the following assertion must be {@code true}:
* <pre>{@code instance.equals( type.unserialize(type.serialize(instance)) );}</pre>
*
* @param representation
* The string representation of the type.
*
* @throws DataTypeUnserializationException if representation cannot be turned into an instance of T
*
* @see #serialize()
*/
T unserialize(String representation);
}
|
How to use the new datatype within the workflow diagram editor?¶
Important
Feature not implemented yet.