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
    Wraps the given canonical and if needed splits off the version part.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the URL part of the canonical (everything before the "|" character, or the complete canonical if the character is not present).
    Returns the version part of the source canonical (everything after the "|" character.
    getVersionOr(String alternative)
    Returns the version of this pair, or the parameter alternative, if the version of this pair is null.
    boolean
    Determines if the encapsulated version of this pair is not null and not an empty string.
    boolean
    Determines if the version part of the canonical is not null
    of(String target)
    Static factory method, that invokes the CanonicalPair constructor with the given argument.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CanonicalPair

      public CanonicalPair(String target)
      Wraps the given canonical and if needed splits off the version part.

      The given parameter target is expected to be a canonical.

      Parameters:
      target - canonical to create a url, version pair from. May be null.
  • Method Details

    • of

      public static CanonicalPair of(String target)
      Static factory method, that invokes the CanonicalPair constructor with the given argument.
      Parameters:
      target - the canonical to be split. May be null.
      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 was null
    • 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 was null, or canonical contains no "|" character.
    • hasVersion

      public boolean hasVersion()
      Determines if the version part of the canonical is not null
      Returns:
      true if version is not null, otherwise false
    • getVersionOr

      public String getVersionOr(String alternative)
      Returns the version of this pair, or the parameter alternative, if the version of this pair is null.
      Parameters:
      alternative - to be returned from this method if the encapsulated version is null.
      Returns:
      either the held version, or alternative, if version is null
    • hasNonEmptyVersion

      public boolean hasNonEmptyVersion()
      Determines if the encapsulated version of this pair is not null and not an empty string.
      Returns:
      true if the version of this pair is not null and not an empty string, false otherwise