add primitive type factory

This commit is contained in:
Grahame Grieve 2021-01-14 12:18:17 +11:00
parent 3ab5444dca
commit fa7341ca44
1 changed files with 27 additions and 0 deletions

View File

@ -678,5 +678,32 @@ public class ResourceFactory extends Factory {
} }
} }
public static DataType createPrimitive(String type, String value) {
switch (type) {
case "boolean": return new BooleanType(value);
case "integer": return new IntegerType(value);
case "integer64": return new Integer64Type(value);
case "string": return new StringType(value);
case "decimal": return new DecimalType(value);
case "uri": return new UriType(value);
case "url": return new UrlType(value);
case "canonical": return new CanonicalType(value);
case "base64Binary": return new Base64BinaryType(value);
case "instant": return new InstantType(value);
case "date": return new DateType(value);
case "dateTime": return new DateTimeType(value);
case "time": return new TimeType(value);
case "code": return new CodeType(value);
case "oid": return new OidType(value);
case "id": return new IdType(value);
case "markdown": return new MarkdownType(value);
case "unsignedInt": return new UnsignedIntType(value);
case "positiveInt": return new PositiveIntType(value);
case "uuid": return new UuidType(value);
default:
throw new FHIRException("Unknown Primitive Type '"+type+"'");
}
}
} }