public abstract class SerializingCustomDatatype<T> extends java.lang.Object implements CustomDatatype<T>
CustomDatatype.Summary
Constructor and Description |
---|
SerializingCustomDatatype() |
Modifier and Type | Method and Description |
---|---|
abstract T |
deserialize(java.lang.String serializedValue) |
CustomDatatype.Summary |
doGetTextSummary(T typedValue)
Most implementations should override this method to return plain-text summary of the typed value, as defined
by
CustomDatatype.getTextSummary(String) . |
T |
fromReferenceString(java.lang.String persistedValue)
Converts a reference string to its typed value.
|
java.lang.String |
getReferenceStringForValue(T typedValue)
Gets the reference string that would be persisted for the given typed value.
|
CustomDatatype.Summary |
getTextSummary(java.lang.String referenceString)
Default implementation calls
doGetTextSummary(Object) . |
java.lang.String |
save(T typedValue,
java.lang.String existingValueReference)
The OpenMRS service layer calls this method when a custom value of this datatype is saved (created or edited).
|
abstract java.lang.String |
serialize(T typedValue) |
void |
setConfiguration(java.lang.String config)
Does nothing in the default implementation
|
void |
validate(T typedValue)
Passes for all non-null values in the default implementation
|
public abstract java.lang.String serialize(T typedValue)
typedValue
- (has already had validate called)public abstract T deserialize(java.lang.String serializedValue)
serializedValue
- public CustomDatatype.Summary doGetTextSummary(T typedValue)
CustomDatatype.getTextSummary(String)
. If deserialize(String)
is expensive, then the
implementation should override getTextSummary(String)
instead.
The default implementation returns typedValue.toString(), and indicates it is complete.typedValue
- public void setConfiguration(java.lang.String config)
setConfiguration
in interface CustomDatatype<T>
CustomDatatype.setConfiguration(java.lang.String)
public void validate(T typedValue) throws InvalidCustomValueException
validate
in interface CustomDatatype<T>
InvalidCustomValueException
CustomDatatype.validate(java.lang.Object)
public T fromReferenceString(java.lang.String persistedValue) throws InvalidCustomValueException
CustomDatatype
fromReferenceString
in interface CustomDatatype<T>
InvalidCustomValueException
- if the persisted value is illegal (perhaps because datatype configuration
was changed since this value was persisted)CustomDatatype.fromReferenceString(java.lang.String)
public java.lang.String save(T typedValue, java.lang.String existingValueReference) throws InvalidCustomValueException
CustomDatatype
save
in interface CustomDatatype<T>
existingValueReference
- If null, the custom value is being saved for the first time. If not null, this custom value has
been saved before with the given reference. Implementations may choose to return the same value reference if they are overwriting
the old value on remote storage.InvalidCustomValueException
CustomDatatype.save(java.lang.Object, java.lang.String)
public java.lang.String getReferenceStringForValue(T typedValue) throws java.lang.UnsupportedOperationException
CustomDatatype
getReferenceStringForValue
in interface CustomDatatype<T>
java.lang.UnsupportedOperationException
- if it is not feasible to calculate this efficiently (e.g. you'd need to go to remote storage)CustomDatatype.getReferenceStringForValue(java.lang.Object)
public CustomDatatype.Summary getTextSummary(java.lang.String referenceString)
doGetTextSummary(Object)
. Most implementations should override that
other method, but if deserialize(String)
is expensive, then you should override this method instead.getTextSummary
in interface CustomDatatype<T>
CustomDatatype.getTextSummary(java.lang.String)
Copyright © 2018 OpenMRS Inc.. All Rights Reserved.