if (retVal == null && myHaveComponentParts) { if (isLocal() || isUrn()) { return myUnqualifiedId;
/** * Creates a new instance of this ID which is identical, but refers to the * specific version of this resource ID noted by theVersion. * * @param theVersion The actual version string, e.g. "1". If theVersion is blank or null, returns the same as {@link #toVersionless()}} * @return A new instance of IdType which is identical, but refers to the * specific version of this resource ID noted by theVersion. */ @Override public IdType withVersion(String theVersion) { if (isBlank(theVersion)) { return toVersionless(); } if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } String existingValue = getValue(); int i = existingValue.indexOf("_history"); String value; if (i > 1) { value = existingValue.substring(0, i - 1); } else { value = existingValue; } return new IdType(value + '/' + "_history" + '/' + theVersion); }
@Override public IdType toUnqualifiedVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart()); }
@Override public IdType withResourceType(String theResourceName) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theResourceName, getIdPart(), getVersionIdPart()); }
@Override public IdType toVersionless() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getBaseUrl(), getResourceType(), getIdPart(), null); }
/** * Returns a new IdType containing this IdType's values but with no server * base URL if one is present in this IdType. For example, if this IdType * contains the ID "http://foo/Patient/1", this method will return a new * IdType containing ID "Patient/1". */ @Override public IdType toUnqualified() { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(getResourceType(), getIdPart(), getVersionIdPart()); }
/** * 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). Essentially, because IdType can contain either a * complete URL or a partial one (or even jut a simple ID), this method may be * used to translate into a complete URL. * * @param theServerBase * The server base (e.g. "http://example.com/fhir") * @param theResourceType * The resource name (e.g. "Patient") * @return A fully qualified URL for this ID (e.g. * "http://example.com/fhir/Patient/1") */ @Override public IdType withServerBase(String theServerBase, String theResourceType) { if (isLocal() || isUrn()) { return new IdType(getValueAsString()); } return new IdType(theServerBase, theResourceType, getIdPart(), getVersionIdPart()); }