Package org.hl7.fhir.r4.model
Class DecimalType
- java.lang.Object
-
- org.hl7.fhir.r4.model.Base
-
- org.hl7.fhir.r4.model.Element
-
- org.hl7.fhir.r4.model.Type
-
- org.hl7.fhir.r4.model.PrimitiveType<BigDecimal>
-
- org.hl7.fhir.r4.model.DecimalType
-
- All Implemented Interfaces:
ca.uhn.fhir.model.api.IElement,Externalizable,Serializable,Comparable<DecimalType>,org.hl7.fhir.instance.model.api.IBase,org.hl7.fhir.instance.model.api.IBaseDatatype,org.hl7.fhir.instance.model.api.IBaseDecimalDatatype,org.hl7.fhir.instance.model.api.IBaseElement,org.hl7.fhir.instance.model.api.IBaseHasExtensions,org.hl7.fhir.instance.model.api.IPrimitiveType<BigDecimal>
public class DecimalType extends PrimitiveType<BigDecimal> implements Comparable<DecimalType>, org.hl7.fhir.instance.model.api.IBaseDecimalDatatype
Primitive type "decimal" in FHIR: A rational number- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DecimalType()ConstructorDecimalType(double theValue)ConstructorDecimalType(long theValue)ConstructorDecimalType(String theValue)ConstructorDecimalType(BigDecimal theValue)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(DecimalType theObj)DecimalTypecopy()protected Stringencode(BigDecimal theValue)Subclasses must override to convert a "coerced" value into an encoded one.StringfhirType()intgetValueAsInteger()Gets the value as an integer, usingBigDecimal.intValue()NumbergetValueAsNumber()protected BigDecimalparse(String theValue)Subclasses must override to convert an encoded representation of this datatype into a "coerced" onevoidround(int thePrecision)Rounds the value to the given previsionvoidround(int thePrecision, RoundingMode theRoundingMode)Rounds the value to the given previsionDecimalTypesetRepresentation(String value)A parser can provide a literal representation for the decimal value that preserves the presented form.voidsetValue(double theValue)Sets a new value using a doublevoidsetValue(long theValue)Sets a new value using a longvoidsetValueAsInteger(int theValue)Sets a new value using an integer-
Methods inherited from class org.hl7.fhir.r4.model.PrimitiveType
asStringValue, equalsDeep, equalsShallow, forceStringValue, fromStringValue, getProperty, getTypesForProperty, getValue, getValueAsString, hashCode, hasPrimitiveValue, hasValue, isEmpty, isPrimitive, makeProperty, primitiveValue, readExternal, setProperty, setProperty, setValue, setValueAsString, toString, typedCopy, updateStringValue, writeExternal
-
Methods inherited from class org.hl7.fhir.r4.model.Element
addChild, addExtension, addExtension, addExtension, copyValues, getExtension, getExtensionByUrl, getExtensionFirstRep, getExtensionsByUrl, getExtensionString, getId, getIdBase, getIdElement, getNamedProperty, hasExtension, hasExtension, hasId, hasIdElement, isDisallowExtensions, listChildren, noExtensions, removeExtension, setDisallowExtensions, setExtension, setId, setIdBase, setIdElement
-
Methods inherited from class org.hl7.fhir.r4.model.Base
castToAddress, castToAnnotation, castToAttachment, castToBase64Binary, castToBoolean, castToCanonical, castToCode, castToCodeableConcept, castToCoding, castToContactDetail, castToContactPoint, castToContributor, castToDataRequirement, castToDate, castToDateTime, castToDecimal, castToDosage, castToDuration, castToElementDefinition, castToExpression, castToExtension, castToHumanName, castToId, castToIdentifier, castToInstant, castToInteger, castToMarkdown, castToMarketingStatus, castToMeta, castToMoney, castToNarrative, castToOid, castToParameterDefinition, castToPeriod, castToPopulation, castToPositiveInt, castToProdCharacteristic, castToProductShelfLife, castToQuantity, castToRange, castToRatio, castToReference, castToRelatedArtifact, castToResource, castToSampledData, castToSignature, castToSimpleQuantity, castToString, castToSubstanceAmount, castToTime, castToTiming, castToTriggerDefinition, castToType, castToUnsignedInt, castToUri, castToUrl, castToUsageContext, castToXhtml, castToXhtmlString, children, clearUserData, compareDeep, compareDeep, compareDeep, compareDeep, compareValues, compareValues, dateTimeValue, equals, getChildByName, getFormatCommentsPost, getFormatCommentsPre, getNamedProperty, getUserData, getUserInt, getUserString, hasFormatComment, hasType, hasUserData, isBooleanPrimitive, isDateTime, isMetadataBased, isResource, listChildrenByName, listChildrenByName, setUserData, setUserDataINN
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IBase
getFormatCommentsPost, getFormatCommentsPre, getUserData, hasFormatComment, isEmpty, setUserData
-
Methods inherited from interface org.hl7.fhir.instance.model.api.IBaseElement
getUserData, setUserData
-
-
-
-
Constructor Detail
-
DecimalType
public DecimalType()
Constructor
-
DecimalType
public DecimalType(BigDecimal theValue)
Constructor
-
DecimalType
public DecimalType(double theValue)
Constructor
-
DecimalType
public DecimalType(long theValue)
Constructor
-
DecimalType
public DecimalType(String theValue)
Constructor
-
-
Method Detail
-
compareTo
public int compareTo(DecimalType theObj)
- Specified by:
compareToin interfaceComparable<DecimalType>
-
encode
protected String encode(BigDecimal theValue)
Description copied from class:PrimitiveTypeSubclasses must override to convert a "coerced" value into an encoded one.- Specified by:
encodein classPrimitiveType<BigDecimal>- Parameters:
theValue- Will not be null- Returns:
- May return null if the value does not correspond to anything
-
getValueAsInteger
public int getValueAsInteger()
Gets the value as an integer, usingBigDecimal.intValue()
-
getValueAsNumber
public Number getValueAsNumber()
-
parse
protected BigDecimal parse(String theValue)
Description copied from class:PrimitiveTypeSubclasses must override to convert an encoded representation of this datatype into a "coerced" one- Specified by:
parsein classPrimitiveType<BigDecimal>- Parameters:
theValue- Will not be null- Returns:
- May return null if the value does not correspond to anything
-
round
public void round(int thePrecision)
Rounds the value to the given prevision- See Also:
MathContext.getPrecision()
-
round
public void round(int thePrecision, RoundingMode theRoundingMode)
Rounds the value to the given prevision
-
setValueAsInteger
public void setValueAsInteger(int theValue)
Sets a new value using an integer
-
setValue
public void setValue(long theValue)
Sets a new value using a long
-
setValue
public void setValue(double theValue)
Sets a new value using a double
-
copy
public DecimalType copy()
- Specified by:
copyin classPrimitiveType<BigDecimal>
-
setRepresentation
public DecimalType setRepresentation(String value)
A parser can provide a literal representation for the decimal value that preserves the presented form. All sorts of bad things can happen if this method is used to set the string representation to anything other than what was parsed into the actual value. Don't do that- Parameters:
value-- Returns:
-
-