-
Notifications
You must be signed in to change notification settings - Fork 3
Enums
Martin Ledvinka edited this page Mar 20, 2023
·
1 revision
By default, Java enums are serialized/deserialized as strings. That is, for serialization, the toString
method will be used on the specified enum constant. For deserialization, Enum.valueOf
is used.
In case the enum is used as an object property value and its constants are mapped using the @Individual
annotation from JOPA, they will be mapped to the corresponding individuals. See the JOPA Wiki for details on enum mapping in entities if necessary.
For example, if the enum looks as follows:
public enum OwlPropertyType {
@Individual(iri = "http://www.w3.org/2002/07/owl#AnnotationProperty")
ANNOTATION_PROPERTY,
@Individual(iri = "http://www.w3.org/2002/07/owl#DatatypeProperty")
DATATYPE_PROPERTY,
@Individual(iri = "http://www.w3.org/2002/07/owl#ObjectProperty")
OBJECT_PROPERTY;
}
and a class contains an attribute with OwlPropertyType
as value:
@OWLObjectProperty(iri = "http://example.org/attributes/has-property-type")
OwlPropertyType propertyType;
A value of DATATYPE_PROPERTY
will be serialized as (assuming serialization without context):
"http://example.org/attributes/has-property-type": {
"@id": "http://www.w3.org/2002/07/owl#DatatypeProperty"
}
Deserialization works conversely.