Class Link

java.lang.Object
com.genologics.ri.Link
All Implemented Interfaces:
Locatable, Serializable

public class Link extends Object implements Locatable, Serializable
A link provides a URI linking to an additional resource.

The link is modelled on the link element defined by the Atom Syndication Format. The link includes a rel attribute that describes the URI of the link.

See Also:
  • Field Details

    • UNSET

      public static final String UNSET
      Shared constant for use throughout this library to indicate a field is not set.
      See Also:
    • relative

      protected String relative
      The relative part of the link.
    • uri

      protected URI uri
      The URI of the link.
  • Constructor Details

    • Link

      public Link()
      Default constructor.
    • Link

      public Link(String rel)
      Constructor with relative part.
      Parameters:
      rel - The relative part of the link.
    • Link

      public Link(String rel, URI uri)
      Constructor with relative part and URI.
      Parameters:
      rel - The relative part of the link.
      uri - The URI.
    • Link

      public Link(Linkable<?> linkable)
      Constructor from a linkable object.
      Parameters:
      linkable - The linkable object.
  • Method Details

    • getRelative

      public String getRelative()
      Gets the relative part of the link.
      Returns:
      The relative part.
    • setRelative

      public void setRelative(String rel)
      Sets the relative part of the link.
      Parameters:
      rel - The relative part.
    • getUri

      public URI getUri()
      Gets the URI of the link.
      Specified by:
      getUri in interface Locatable
      Returns:
      The URI.
    • setUri

      public void setUri(URI uri)
      Sets the URI of the link.
      Specified by:
      setUri in interface Locatable
      Parameters:
      uri - The URI.
    • toString

      public String toString()
      Gets a string representation of the link.
      Overrides:
      toString in class Object
      Returns:
      The URI as a string, or "unset" if the URI is null.
    • limsIdFromUri

      public static String limsIdFromUri(URI uri)
      Extract the LIMS identifier from a URI. The identifier is the last part of the URI path.
      Parameters:
      uri - The URI.
      Returns:
      The id from the URI path, or null if uri is null.
    • limsIdFromUri

      public static String limsIdFromUri(Locatable thing)
      Extract the LIMS identifier from the URI of a Locatable object.
      Parameters:
      thing - The Locatable object.
      Returns:
      The id from the object's URI, or null if thing is null.