-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move toString to ConversionFunctions and document
- Loading branch information
1 parent
2b15d19
commit 77ec4ec
Showing
2 changed files
with
42 additions
and
14 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
fhirpath/src/main/java/au/csiro/pathling/fhirpath/function/ConversionFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package au.csiro.pathling.fhirpath.function; | ||
|
||
import au.csiro.pathling.fhirpath.StringCoercible; | ||
import au.csiro.pathling.fhirpath.collection.Collection; | ||
import au.csiro.pathling.fhirpath.validation.FhirPathFunction; | ||
import au.csiro.pathling.utilities.Preconditions; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Functions for converting between different types. | ||
* | ||
* @see <a href="https://build.fhir.org/ig/HL7/FHIRPath/#conversion">FHIRPath Specification - | ||
* Conversion</a> | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class ConversionFunctions { | ||
|
||
/** | ||
* If the input collection contains a single item, this function will return a single String if: | ||
* <ul> | ||
* <li>the item in the input collection is a String</li> | ||
* <li>the item in the input collection is an Integer, | ||
* Decimal, Date, Time, DateTime, or Quantity the output will contain its String representation</li> | ||
* <li>the item is a Boolean, where true results in 'true' and false in 'false'.</li> | ||
* </ul> | ||
* If the item is not one of the above types, the result is false. | ||
* | ||
* @param input The input collection | ||
* @return A collection containing the single item as a String, or an empty collection if the | ||
* input collection is empty or contains more than one item. | ||
* @see <a href="https://build.fhir.org/ig/HL7/FHIRPath/#tostring--string">FHIRPath Specification | ||
* - toString</a> | ||
*/ | ||
@FhirPathFunction | ||
@Nonnull | ||
public static Collection toString(@Nonnull final Collection input) { | ||
Preconditions.checkUserInput(input instanceof StringCoercible, | ||
"toString() can only be applied to a StringCoercible path"); | ||
return ((StringCoercible) input).asStringPath(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters