From 13b3601843300a1e40d115940c965a67310446c8 Mon Sep 17 00:00:00 2001 From: Nick Peterson Date: Fri, 20 Nov 2015 12:15:31 -0800 Subject: [PATCH] Make IBoundCodeableConcept and IValueSetEnumBinder extend java.io.serializable; add a test to verify that MaritalStatusCodesEnum in DSTU2 is now serializable. --- .../fhir/model/api/IBoundCodeableConcept.java | 4 +++- .../uhn/fhir/model/api/IValueSetEnumBinder.java | 3 ++- .../fhir/model/dstu2/ModelSerializationTest.java | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IBoundCodeableConcept.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IBoundCodeableConcept.java index 756f565fd00..dc80e5108da 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IBoundCodeableConcept.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IBoundCodeableConcept.java @@ -20,6 +20,8 @@ package ca.uhn.fhir.model.api; * #L% */ -public interface IBoundCodeableConcept { +import java.io.Serializable; + +public interface IBoundCodeableConcept extends Serializable { } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IValueSetEnumBinder.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IValueSetEnumBinder.java index 48b1246818e..a82297c6eef 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IValueSetEnumBinder.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IValueSetEnumBinder.java @@ -21,8 +21,9 @@ package ca.uhn.fhir.model.api; */ +import java.io.Serializable; -public interface IValueSetEnumBinder> { +public interface IValueSetEnumBinder> extends Serializable { T fromCodeString(String theCodeString); diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/dstu2/ModelSerializationTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/dstu2/ModelSerializationTest.java index 340fd2371c3..16534773a10 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/dstu2/ModelSerializationTest.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/dstu2/ModelSerializationTest.java @@ -17,6 +17,7 @@ import ca.uhn.fhir.model.dstu2.composite.AddressDt; import ca.uhn.fhir.model.dstu2.composite.HumanNameDt; import ca.uhn.fhir.model.dstu2.resource.Bundle; import ca.uhn.fhir.model.dstu2.resource.Patient; +import ca.uhn.fhir.model.dstu2.valueset.MaritalStatusCodesEnum; import ca.uhn.fhir.parser.IParser; public class ModelSerializationTest { @@ -55,4 +56,19 @@ public class ModelSerializationTest { } + /** + * Verify that MaritalStatusCodeEnum (and, by extension, BoundCodeableConcepts in general) are serializable. + * Author: Nick Peterson (nrpeterson@gmail.com) + */ + @Test + public void testBoundCodeableConceptSerialization() { + MaritalStatusCodesEnum maritalStatus = MaritalStatusCodesEnum.M; + byte[] bytes = SerializationUtils.serialize(maritalStatus); + assertTrue(bytes.length > 0); + + MaritalStatusCodesEnum deserialized = SerializationUtils.deserialize(bytes); + assertEquals(maritalStatus.getCode(), deserialized.getCode()); + assertEquals(maritalStatus.getSystem(), deserialized.getSystem()); + } + }