From f2f09d03df78b832bb15c52241f817eb9d8a9183 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 29 Oct 2014 16:23:19 -0400 Subject: [PATCH] Add constructor and javadocs --- .../uhn/fhir/rest/param/TokenOrListParam.java | 73 ++++++++++++++----- 1 file changed, 53 insertions(+), 20 deletions(-) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/TokenOrListParam.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/TokenOrListParam.java index 3915309e094..ad733aee9ce 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/TokenOrListParam.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/TokenOrListParam.java @@ -26,14 +26,58 @@ import ca.uhn.fhir.model.base.composite.BaseIdentifierDt; * #L% */ +/** + * This class represents a restful search operation parameter for an "OR list" of tokens (in other words, a + * list which can contain one-or-more tokens, where the server should return results matching any of the tokens) + */ +public class TokenOrListParam extends BaseOrListParam { -public class TokenOrListParam extends BaseOrListParam { - - @Override - TokenParam newInstance() { - return new TokenParam(); + /** + * Create a new empty token "OR list" + */ + public TokenOrListParam() { } - + + /** + * Create a new token "OR list" with a single token, or multiple tokens which have the same system value + * + * @param theSystem + * The system to use for the one token to pre-populate in this list + * @param theValues + * The values to use for the one token to pre-populate in this list + */ + public TokenOrListParam(String theSystem, String... theValues) { + for (String next : theValues) { + add(theSystem, next); + } + } + + /** + * Convenience method which adds a token to this OR list using the system and code from a coding + */ + public void add(BaseCodingDt theCodingDt) { + add(new TokenParam(theCodingDt)); + } + + /** + * Convenience method which adds a token to this OR list using the system and value from an identifier + */ + public void add(BaseIdentifierDt theIdentifierDt) { + add(new TokenParam(theIdentifierDt)); + } + + /** + * Add a new token to this list + * + * @param theSystem + * The system to use for the one token to pre-populate in this list + * @param theValue + * The value to use for the one token to pre-populate in this list + */ + public void add(String theSystem, String theValue) { + add(new TokenParam(theSystem, theValue)); + } + public List getListAsCodings() { ArrayList retVal = new ArrayList(); for (TokenParam next : getValuesAsQueryTokens()) { @@ -45,20 +89,9 @@ public class TokenOrListParam extends BaseOrListParam { return retVal; } - /** - * Convenience method which adds a token to this OR list - * using the system and code from a coding - */ - public void add(BaseCodingDt theCodingDt) { - add(new TokenParam(theCodingDt)); - } - - /** - * Convenience method which adds a token to this OR list - * using the system and value from an identifier - */ - public void add(BaseIdentifierDt theIdentifierDt) { - add(new TokenParam(theIdentifierDt)); + @Override + TokenParam newInstance() { + return new TokenParam(); } }