From 9cab735dfcd18e587a6bdb34303d496bec812e2d Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Sat, 3 Nov 2018 19:51:19 +0000 Subject: [PATCH] Add common interface for preference values --- .../refine/preference/PreferenceValue.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 main/src/com/google/refine/preference/PreferenceValue.java diff --git a/main/src/com/google/refine/preference/PreferenceValue.java b/main/src/com/google/refine/preference/PreferenceValue.java new file mode 100644 index 000000000..78d8e64f2 --- /dev/null +++ b/main/src/com/google/refine/preference/PreferenceValue.java @@ -0,0 +1,25 @@ +package com.google.refine.preference; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * Interface to be extended by all objects stored + * in the preferences. This ensures that their full class + * name is serialized with them. They should implement + * Jackson deserialization as usual. + * + * @author Antonin Delpeuch + */ + +@JsonTypeInfo( + use=JsonTypeInfo.Id.CLASS, + include=JsonTypeInfo.As.PROPERTY, + property="class") +public interface PreferenceValue { + + @JsonProperty("class") + public default String getClassName() { + return this.getClass().getName(); + } +}