public final class IdType extends UriType implements IPrimitiveType<String>, IIdType
A whole number in the range 0 to 2^64-1 (optionally represented in hex),
a uuid, an oid, or any other combination of lowercase letters, numerals, "-"
and ".", with a length limit of 36 characters
This class contains that logical ID, and can optionally also contain a relative or absolute URL representing the resource identity. For example, the following are all valid values for IdType, and all might represent the same resource:
123 (just a resource's ID)Patient/123 (a relative identity)http://example.com/Patient/123 (an absolute identity)http://example.com/Patient/123/_history/1 (an absolute identity with a version id)
Patient/123/_history/1 (a relative identity with a version id)
In most situations, you only need to populate the resource's ID (e.g.
123) in resources you are constructing and the encoder will
infer the rest from the context in which the object is being used. On the
other hand, the parser will always try to populate the complete absolute
identity on objects it creates as a convenience.
Regex for ID: [a-z0-9\-\.]{1,36}
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_LENGTH
This is the maximum length for the ID
|
| Constructor and Description |
|---|
IdType()
Create a new empty ID
|
IdType(BigDecimal thePid)
Create a new ID, using a BigDecimal input.
|
IdType(long theId)
Create a new ID using a long
|
IdType(String theValue)
Create a new ID using a string.
|
IdType(String theResourceType,
BigDecimal theIdPart)
Constructor
|
IdType(String theResourceType,
Long theIdPart)
Constructor
|
IdType(String theResourceType,
String theId)
Constructor
|
IdType(String theResourceType,
String theId,
String theVersionId)
Constructor
|
IdType(String theBaseUrl,
String theResourceType,
String theId,
String theVersionId)
Constructor
|
IdType(UriType theUrl)
Creates an ID based on a given URL
|
| Modifier and Type | Method and Description |
|---|---|
void |
applyTo(IBaseResource theResouce) |
BigDecimal |
asBigDecimal()
Deprecated.
Use
getIdPartAsBigDecimal() instead (this method was
deprocated because its name is ambiguous) |
IdType |
copy() |
boolean |
equals(Object theArg0) |
boolean |
equalsIgnoreBase(IdType theId)
Returns true if this IdType matches the given IdType in terms of resource
type and ID, but ignores the URL base
|
String |
fhirType() |
String |
getBaseUrl()
Returns the portion of this resource ID which corresponds to the server
base URL.
|
String |
getIdPart()
Returns only the logical ID part of this ID.
|
BigDecimal |
getIdPartAsBigDecimal()
Returns the unqualified portion of this ID as a big decimal, or
null if the value is null |
Long |
getIdPartAsLong()
Returns the unqualified portion of this ID as a
Long, or
null if the value is null |
String |
getResourceType() |
String |
getValue()
Returns the value of this ID.
|
String |
getValueAsString() |
String |
getVersionIdPart() |
Long |
getVersionIdPartAsLong() |
boolean |
hasBaseUrl()
Returns true if this ID has a base url
|
int |
hashCode() |
boolean |
hasIdPart() |
boolean |
hasResourceType() |
boolean |
hasVersionIdPart() |
boolean |
isAbsolute()
Returns
true if this ID contains an absolute URL (in other
words, a URL starting with "http://" or "https://" |
boolean |
isEmpty() |
boolean |
isIdPartValid() |
boolean |
isIdPartValidLong()
Returns
true if the unqualified ID is a valid Long
value (in other words, it consists only of digits) |
boolean |
isLocal()
Returns
true if the ID is a local reference (in other words,
it begins with the '#' character) |
boolean |
isVersionIdPartValidLong() |
static IdType |
newRandomUuid()
Construct a new ID with with form "urn:uuid:[UUID]" where [UUID] is a new,
randomly created UUID generated by
UUID.randomUUID() |
static IdType |
of(IBaseResource theResouce)
Retrieves the ID from the given resource instance
|
IIdType |
setParts(String theBaseUrl,
String theResourceType,
String theIdPart,
String theVersionIdPart) |
IdType |
setValue(String theValue)
Set the value
|
void |
setValueAsString(String theValue)
Set the value
|
String |
toString() |
IdType |
toUnqualified()
Returns a new IdType containing this IdType's values but with no server
base URL if one is present in this IdType.
|
IdType |
toUnqualifiedVersionless() |
IdType |
toVersionless() |
IdType |
withResourceType(String theResourceName) |
IdType |
withServerBase(String theServerBase,
String theResourceType)
Returns a view of this ID as a fully qualified URL, given a server base and
resource name (which will only be used if the ID does not already contain
those respective parts).
|
IdType |
withVersion(String theVersion)
Creates a new instance of this ID which is identical, but refers to the
specific version of this resource ID noted by theVersion.
|
encode, equals, equalsDeep, fromOid, parseasStringValue, equalsShallow, fromStringValue, hasValue, isPrimitive, primitiveValue, readExternal, typedCopy, updateStringValue, writeExternaladdChild, addExtension, addExtension, addExtension, copyValues, getExtension, getExtensionFirstRep, getExtensionsByUrl, getExtensionString, getId, getIdBase, getIdElement, getProperty, getTypesForProperty, hasExtension, hasExtension, hasId, hasIdElement, listChildren, makeProperty, setExtension, setId, setIdBase, setIdElement, setProperty, setPropertycastToAddress, castToAnnotation, castToAttachment, castToBase64Binary, castToBoolean, castToCode, castToCodeableConcept, castToCoding, castToContactDetail, castToContactPoint, castToContributor, castToDataRequirement, castToDate, castToDateTime, castToDecimal, castToDosage, castToDuration, castToElementDefinition, castToExtension, castToHumanName, castToId, castToIdentifier, castToInstant, castToInteger, castToMarkdown, castToMeta, castToMoney, castToNarrative, castToOid, castToParameterDefinition, castToPeriod, castToPositiveInt, castToQuantity, castToRange, castToRatio, castToReference, castToRelatedArtifact, castToResource, castToSampledData, castToSignature, castToSimpleQuantity, castToString, castToTime, castToTiming, castToTriggerDefinition, castToType, castToUnsignedInt, castToUri, castToUsageContext, castToXhtml, castToXhtmlString, children, clearUserData, compareDeep, compareDeep, compareDeep, compareValues, compareValues, equals, getChildByName, getFormatCommentsPost, getFormatCommentsPre, getUserData, getUserInt, getUserString, hasFormatComment, hasPrimitiveValue, hasType, hasUserData, isMetadataBased, isResource, listChildrenByName, listChildrenByName, setUserData, setUserDataINNclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetFormatCommentsPost, getFormatCommentsPre, hasFormatCommentaddExtension, getExtension, hasExtensionpublic static final int MAX_LENGTH
public IdType()
public IdType(BigDecimal thePid)
BigDecimal.toPlainString() to generate the string representation.public IdType(long theId)
public IdType(String theValue)
Description: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
public IdType(String theResourceType, BigDecimal theIdPart)
theResourceType - The resource type (e.g. "Patient")theIdPart - The ID (e.g. "123")public IdType(String theResourceType, Long theIdPart)
theResourceType - The resource type (e.g. "Patient")theIdPart - The ID (e.g. "123")public IdType(String theResourceType, String theId)
theResourceType - The resource type (e.g. "Patient")theId - The ID (e.g. "123")public IdType(String theResourceType, String theId, String theVersionId)
theResourceType - The resource type (e.g. "Patient")theId - The ID (e.g. "123")theVersionId - The version ID ("e.g. "456")public IdType(String theBaseUrl, String theResourceType, String theId, String theVersionId)
theBaseUrl - The server base URL (e.g. "http://example.com/fhir")theResourceType - The resource type (e.g. "Patient")theId - The ID (e.g. "123")theVersionId - The version ID ("e.g. "456")public void applyTo(IBaseResource theResouce)
@Deprecated public BigDecimal asBigDecimal()
getIdPartAsBigDecimal() instead (this method was
deprocated because its name is ambiguous)public boolean equalsIgnoreBase(IdType theId)
public String getBaseUrl()
http://example.com/fhir/Patient/123 the base URL would be
http://example.com/fhir.
This method may return null if the ID contains no base (e.g. "Patient/123")
getBaseUrl in interface IIdTypepublic String getIdPart()
public BigDecimal getIdPartAsBigDecimal()
null if the value is nullNumberFormatException - If the value is not a valid BigDecimalpublic Long getIdPartAsLong()
Long, or
null if the value is nullgetIdPartAsLong in interface IIdTypeNumberFormatException - If the value is not a valid Longpublic String getResourceType()
getResourceType in interface IIdTypepublic String getValue()
getIdPart() to
get just the ID portion.getValue in interface IIdTypegetValue in interface IPrimitiveType<String>getValue in class PrimitiveType<String>getIdPart()public String getValueAsString()
getValueAsString in interface IPrimitiveType<String>getValueAsString in class PrimitiveType<String>public String getVersionIdPart()
getVersionIdPart in interface IIdTypepublic Long getVersionIdPartAsLong()
getVersionIdPartAsLong in interface IIdTypepublic boolean hasBaseUrl()
hasBaseUrl in interface IIdTypegetBaseUrl()public boolean hasResourceType()
hasResourceType in interface IIdTypepublic boolean hasVersionIdPart()
hasVersionIdPart in interface IIdTypepublic boolean isAbsolute()
true if this ID contains an absolute URL (in other
words, a URL starting with "http://" or "https://"isAbsolute in interface IIdTypepublic boolean isEmpty()
public boolean isIdPartValid()
isIdPartValid in interface IIdTypepublic boolean isIdPartValidLong()
true if the unqualified ID is a valid Long
value (in other words, it consists only of digits)isIdPartValidLong in interface IIdTypepublic boolean isLocal()
true if the ID is a local reference (in other words,
it begins with the '#' character)public boolean isVersionIdPartValidLong()
isVersionIdPartValidLong in interface IIdTypepublic IdType setValue(String theValue)
Description: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
setValue in interface IIdTypesetValue in interface IPrimitiveType<String>setValue in class PrimitiveType<String>public void setValueAsString(String theValue)
Description: A whole number in the range 0 to 2^64-1 (optionally represented in hex), a uuid, an oid, or any other combination of lowercase letters, numerals, "-" and ".", with a length limit of 36 characters.
regex: [a-z0-9\-\.]{1,36}
setValueAsString in interface IPrimitiveType<String>setValueAsString in class PrimitiveType<String>public String toString()
toString in class PrimitiveType<String>public IdType toUnqualified()
toUnqualified in interface IIdTypepublic IdType toUnqualifiedVersionless()
toUnqualifiedVersionless in interface IIdTypepublic IdType toVersionless()
toVersionless in interface IIdTypepublic IdType withResourceType(String theResourceName)
withResourceType in interface IIdTypepublic IdType withServerBase(String theServerBase, String theResourceType)
withServerBase in interface IIdTypetheServerBase - The server base (e.g. "http://example.com/fhir")theResourceType - The resource name (e.g. "Patient")public IdType withVersion(String theVersion)
withVersion in interface IIdTypetheVersion - The actual version string, e.g. "1"public static IdType newRandomUuid()
UUID.randomUUID()public static IdType of(IBaseResource theResouce)
Copyright © 2014–2017 University Health Network. All rights reserved.