Add tests and changes for Decimal
This commit is contained in:
parent
90dad874ec
commit
d0feacaaa8
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal10_30 {
|
||||
public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
ConversionContext10_30.INSTANCE.getVersionConvertor_10_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal10_40 {
|
||||
public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
ConversionContext10_40.INSTANCE.getVersionConvertor_10_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal10_50 {
|
||||
public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
org.hl7.fhir.dstu2.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2.model.DecimalType();
|
||||
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal14_30 {
|
||||
public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
ConversionContext14_30.INSTANCE.getVersionConvertor_14_30().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal14_40 {
|
||||
public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = new org.hl7.fhir.r4.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
ConversionContext14_40.INSTANCE.getVersionConvertor_14_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal14_50 {
|
||||
public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu2016may.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = new org.hl7.fhir.r5.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu2016may.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
if (src.hasValue()) tgt.setValue(src.getValue());
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu2016may.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu2016may.model.DecimalType();
|
||||
ConversionContext14_50.INSTANCE.getVersionConvertor_14_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal30_40 {
|
||||
public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
ConversionContext30_40.INSTANCE.getVersionConvertor_30_40().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal30_50 {
|
||||
public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.dstu3.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.dstu3.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValue()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
org.hl7.fhir.dstu3.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.dstu3.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.dstu3.model.DecimalType();
|
||||
ConversionContext30_50.INSTANCE.getVersionConvertor_30_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ import org.hl7.fhir.exceptions.FHIRException;
|
|||
|
||||
public class Decimal40_50 {
|
||||
public static org.hl7.fhir.r5.model.DecimalType convertDecimal(org.hl7.fhir.r4.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValue()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
org.hl7.fhir.r5.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r5.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r5.model.DecimalType();
|
||||
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
||||
public static org.hl7.fhir.r4.model.DecimalType convertDecimal(org.hl7.fhir.r5.model.DecimalType src) throws FHIRException {
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValue()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
org.hl7.fhir.r4.model.DecimalType tgt = src.hasValue() ? new org.hl7.fhir.r4.model.DecimalType(src.getValueAsString()) : new org.hl7.fhir.r4.model.DecimalType();
|
||||
ConversionContext40_50.INSTANCE.getVersionConvertor_40_50().copyElement(src, tgt);
|
||||
return tgt;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.lang.reflect.Array;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
@ -23,6 +24,20 @@ public class VersionConvertorPrimitiveTypeTests {
|
|||
"true", "false"
|
||||
};
|
||||
|
||||
private static String[] DECIMAL_STRINGS = {
|
||||
BigDecimal.valueOf(-Double.MAX_VALUE).toPlainString(),
|
||||
"-12345",
|
||||
"-12.300",
|
||||
"-12.3000",
|
||||
"0",
|
||||
"0.0",
|
||||
"0.00",
|
||||
"12.300",
|
||||
"12.3000",
|
||||
"12345",
|
||||
BigDecimal.valueOf(Double.MAX_VALUE).toPlainString()
|
||||
};
|
||||
|
||||
private static String[] ID_STRINGS = {
|
||||
"345e3443345343f3453.t34g5348t3-45t34"
|
||||
};
|
||||
|
@ -200,6 +215,45 @@ public class VersionConvertorPrimitiveTypeTests {
|
|||
org.hl7.fhir.r5.model.CodeType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
STRING_STRINGS),
|
||||
|
||||
//Decimal
|
||||
getConversionParams(VersionConvertorFactory_10_30.class,
|
||||
org.hl7.fhir.dstu2.model.DecimalType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.dstu3.model.DecimalType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_10_40.class,
|
||||
org.hl7.fhir.dstu2.model.DecimalType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.r4.model.DecimalType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_10_50.class,
|
||||
org.hl7.fhir.dstu2.model.DecimalType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
org.hl7.fhir.r5.model.DecimalType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_14_30.class,
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.dstu3.model.DecimalType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_14_40.class,
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.r4.model.DecimalType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_14_50.class,
|
||||
org.hl7.fhir.dstu2016may.model.DecimalType.class, org.hl7.fhir.dstu2016may.model.Type.class,
|
||||
org.hl7.fhir.r5.model.DecimalType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_30_40.class,
|
||||
org.hl7.fhir.dstu3.model.DecimalType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
org.hl7.fhir.r4.model.DecimalType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_30_50.class,
|
||||
org.hl7.fhir.dstu3.model.DecimalType.class, org.hl7.fhir.dstu3.model.Type.class,
|
||||
org.hl7.fhir.r5.model.DecimalType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
DECIMAL_STRINGS),
|
||||
getConversionParams(VersionConvertorFactory_40_50.class,
|
||||
org.hl7.fhir.r4.model.DecimalType.class, org.hl7.fhir.r4.model.Type.class,
|
||||
org.hl7.fhir.r5.model.DecimalType.class, org.hl7.fhir.r5.model.DataType.class,
|
||||
DECIMAL_STRINGS),
|
||||
|
||||
|
||||
//Id
|
||||
getConversionParams(VersionConvertorFactory_10_30.class,
|
||||
org.hl7.fhir.dstu2.model.IdType.class, org.hl7.fhir.dstu2.model.Type.class,
|
||||
|
|
|
@ -81,8 +81,7 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
* Constructor
|
||||
*/
|
||||
public DecimalType(String theValue) {
|
||||
setValue(new BigDecimal(theValue));
|
||||
setRepresentation(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,6 +151,11 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
setValue(BigDecimal.valueOf(theValue));
|
||||
}
|
||||
|
||||
public void setValueAsString(String theString) {
|
||||
setValue(new BigDecimal(theString));
|
||||
setRepresentation(theString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value using a long
|
||||
*/
|
||||
|
|
|
@ -81,8 +81,7 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
* Constructor
|
||||
*/
|
||||
public DecimalType(String theValue) {
|
||||
setValue(new BigDecimal(theValue));
|
||||
setRepresentation(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -152,6 +151,11 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
setValue(BigDecimal.valueOf(theValue));
|
||||
}
|
||||
|
||||
public void setValueAsString(String theString) {
|
||||
setValue(new BigDecimal(theString));
|
||||
setRepresentation(theString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new value using a long
|
||||
*/
|
||||
|
|
|
@ -81,8 +81,7 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
* Constructor
|
||||
*/
|
||||
public DecimalType(String theValue) {
|
||||
setValue(new BigDecimal(theValue));
|
||||
setRepresentation(theValue);
|
||||
setValueAsString(theValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -166,6 +165,11 @@ public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable
|
|||
setValue(BigDecimal.valueOf(theValue));
|
||||
}
|
||||
|
||||
public void setValueAsString(String theString) {
|
||||
setValue(new BigDecimal(theString));
|
||||
setRepresentation(theString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecimalType copy() {
|
||||
DecimalType ret = new DecimalType(getValue());
|
||||
|
|
Loading…
Reference in New Issue