public abstract class SerializingCustomDatatype<T> extends Object implements CustomDatatype<T>
CustomDatatype.Summary
Constructor and Description |
---|
SerializingCustomDatatype() |
Modifier and Type | Method and Description |
---|---|
abstract T |
deserialize(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(String persistedValue)
Converts a reference string to its typed value.
|
String |
getReferenceStringForValue(T typedValue)
Gets the reference string that would be persisted for the given typed value.
|
CustomDatatype.Summary |
getTextSummary(String referenceString)
Default implementation calls
doGetTextSummary(Object) . |
String |
save(T typedValue,
String existingValueReference)
The OpenMRS service layer calls this method when a custom value of this datatype is saved (created or edited).
|
abstract String |
serialize(T typedValue) |
void |
setConfiguration(String config)
Does nothing in the default implementation
|
void |
validate(T typedValue)
Passes for all non-null values in the default implementation
|
public abstract String serialize(T typedValue)
typedValue
- (has already had validate called)public abstract T deserialize(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(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(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 String save(T typedValue, 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 String getReferenceStringForValue(T typedValue) throws UnsupportedOperationException
CustomDatatype
getReferenceStringForValue
in interface CustomDatatype<T>
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(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 © 2024 OpenMRS Inc.. All rights reserved.