T
- the Java class used for typed valuespublic interface CustomDatatype<T>
Modifier and Type | Interface and Description |
---|---|
static class |
CustomDatatype.Summary
A short representation of a custom value, along with an indication of whether this is the complete value,
or just a summary.
|
Modifier and Type | Method and Description |
---|---|
T |
fromReferenceString(String referenceString)
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)
Converts a reference string to a short (generally < 100 characters) plain-text representation of its value.
|
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).
|
void |
setConfiguration(String config)
A
CustomValueDescriptor defines both a datatype and its configuration (e.g. a regex for a RegexValidatedString datatype). |
void |
validate(T typedValue)
Validates the given value to see if it is a legal value for the given handler.
|
void setConfiguration(String config)
CustomValueDescriptor
defines both a datatype and its configuration (e.g. a regex for a RegexValidatedString datatype).
The framework will instantiate datatypes and call this method to set that configuration. Subclasses should define the format
of this configuration.config
- String save(T typedValue, String existingValueReference) throws InvalidCustomValueException
typedValue
- 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
String getReferenceStringForValue(T typedValue) throws UnsupportedOperationException
typedValue
- UnsupportedOperationException
- if it is not feasible to calculate this efficiently (e.g. you'd need to go to remote storage)T fromReferenceString(String referenceString) throws InvalidCustomValueException
referenceString
- InvalidCustomValueException
- if the persisted value is illegal (perhaps because datatype configuration
was changed since this value was persisted)CustomDatatype.Summary getTextSummary(String referenceString)
referenceString
- void validate(T typedValue) throws InvalidCustomValueException
typedValue
- InvalidCustomValueException
Copyright © 2024 OpenMRS Inc.. All rights reserved.