Package org.hl7.fhir.utilities
Class CanonicalPair
- java.lang.Object
-
- org.hl7.fhir.utilities.CanonicalPair
-
public class CanonicalPair extends Object
Abstraction that splits a canonical in form of<url>|<version>into a URL and a version part.
-
-
Constructor Summary
Constructors Constructor Description CanonicalPair(String target)Wraps the given canonical and if needed splits off the version part.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetUrl()Returns the URL part of the canonical (everything before the"|"character, or the complete canonical if the character is not present).StringgetVersion()Returns the version part of the source canonical (everything after the"|"character.StringgetVersionOr(String alternative)Returns the version of this pair, or the parameteralternative, if the version of this pair isnull.booleanhasNonEmptyVersion()Determines if the encapsulated version of this pair is notnulland not an empty string.booleanhasVersion()Determines if the version part of the canonical is notnullstatic CanonicalPairof(String target)Static factory method, that invokes theCanonicalPair constructorwith the given argument.
-
-
-
Constructor Detail
-
CanonicalPair
public CanonicalPair(String target)
Wraps the given canonical and if needed splits off the version part.The given parameter
targetis expected to be a canonical.- Parameters:
target- canonical to create a url, version pair from. May benull.
-
-
Method Detail
-
of
public static CanonicalPair of(String target)
Static factory method, that invokes theCanonicalPair constructorwith the given argument.- Parameters:
target- the canonical to be split. May benull.- Returns:
- new instance of CanonicalPair
-
getUrl
public String getUrl()
Returns the URL part of the canonical (everything before the"|"character, or the complete canonical if the character is not present). If the source- Returns:
- URL part of the source canonical. May be
null, if source canonical wasnull
-
getVersion
public String getVersion()
Returns the version part of the source canonical (everything after the"|"character.- Returns:
- version part of the canonical, may be
null, if canonical wasnull, or canonical contains no"|"character.
-
hasVersion
public boolean hasVersion()
Determines if the version part of the canonical is notnull- Returns:
trueif version is notnull, otherwisefalse
-
getVersionOr
public String getVersionOr(String alternative)
Returns the version of this pair, or the parameteralternative, if the version of this pair isnull.- Parameters:
alternative- to be returned from this method if the encapsulated version isnull.- Returns:
- either the held version, or
alternative, if version isnull
-
hasNonEmptyVersion
public boolean hasNonEmptyVersion()
Determines if the encapsulated version of this pair is notnulland not an empty string.- Returns:
trueif the version of this pair is notnulland not an empty string,falseotherwise
-
-