Class MirrorNodeRestPath

java.lang.Object
com.hedera.hashgraph.sdk.MirrorNodeRestPath

final class MirrorNodeRestPath extends Object
A path below a mirror node's REST base URL.

The type is the mechanism: no mirror node REST call site can name a foreign host, because the only way to reach MirrorNodeHttpClient is through this type and this type cannot express one. Nothing downstream has to check.

Resolution against the base URL is plain concatenation. Every URL-reference resolver in the JDK — URI.resolve included — lets an absolute or protocol-relative reference replace the host outright, which is exactly the failure this type exists to prevent.

  • Method Details

    • of

      static MirrorNodeRestPath of(String path)
      Build a path.
      Parameters:
      path - a path beginning with /, with no host, no protocol-relative prefix and no .. segment
      Returns:
      the new path
      Throws:
      IllegalArgumentException - if the path could name somewhere other than the mirror node
    • fromNextLink

      static MirrorNodeRestPath fromNextLink(String link)
      Convert a mirror node links.next cursor into a path.

      The mirror node includes the /api/v1 prefix that the base URL already carries, so it is stripped exactly once.

      Parameters:
      link - the links.next value
      Returns:
      the new path
      Throws:
      IllegalArgumentException - if the cursor names a host
    • getValue

      String getValue()
      Extract the path.
      Returns:
      the path, beginning with /
    • resolveAgainst

      String resolveAgainst(String baseUrl)
      Resolve against a mirror node REST base URL by concatenation.
      Parameters:
      baseUrl - the base URL, with or without a trailing slash
      Returns:
      the absolute URL
    • toString

      public String toString()
      Overrides:
      toString in class Object