Class PathOrLink

java.lang.Object
com.dropbox.core.v2.files.PathOrLink

public final class PathOrLink extends Object
This class is an open tagged union. Tagged unions instances are always associated to a specific tag. This means only one of the isAbc() methods will return true. You can use tag() to determine the tag associated with this instance.

Open unions may be extended in the future with additional tags. If a new tag is introduced that this SDK does not recognized, the OTHER value will be used.

  • Field Details

    • OTHER

      public static final PathOrLink OTHER
      Catch-all used for unknown tag values returned by the Dropbox servers.

      Receiving a catch-all value typically indicates this SDK version is not up to date. Consider updating your SDK version to handle the new tags.

  • Method Details

    • tag

      public PathOrLink.Tag tag()
      Returns the tag for this instance.

      This class is a tagged union. Tagged unions instances are always associated to a specific tag. This means only one of the isXyz() methods will return true. Callers are recommended to use the tag value in a switch statement to properly handle the different values for this PathOrLink.

      If a tag returned by the server is unrecognized by this SDK, the PathOrLink.Tag.OTHER value will be used.

      Returns:
      the tag for this instance.
    • isPath

      public boolean isPath()
      Returns true if this instance has the tag PathOrLink.Tag.PATH, false otherwise.
      Returns:
      true if this instance is tagged as PathOrLink.Tag.PATH, false otherwise.
    • path

      public static PathOrLink path(String value)
      Returns an instance of PathOrLink that has its tag set to PathOrLink.Tag.PATH.

      None

      Parameters:
      value - value to assign to this instance.
      Returns:
      Instance of PathOrLink with its tag set to PathOrLink.Tag.PATH.
      Throws:
      IllegalArgumentException - if value does not match pattern " (/(.|[\\r\\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/(.|[\\r\\n])*)?)" or is null.
    • getPathValue

      public String getPathValue()
      This instance must be tagged as PathOrLink.Tag.PATH.
      Returns:
      The String value associated with this instance if isPath() is true.
      Throws:
      IllegalStateException - If isPath() is false.
    • isLink

      public boolean isLink()
      Returns true if this instance has the tag PathOrLink.Tag.LINK, false otherwise.
      Returns:
      true if this instance is tagged as PathOrLink.Tag.LINK, false otherwise.
    • link

      public static PathOrLink link(SharedLinkFileInfo value)
      Returns an instance of PathOrLink that has its tag set to PathOrLink.Tag.LINK.

      None

      Parameters:
      value - value to assign to this instance.
      Returns:
      Instance of PathOrLink with its tag set to PathOrLink.Tag.LINK.
      Throws:
      IllegalArgumentException - if value is null.
    • getLinkValue

      public SharedLinkFileInfo getLinkValue()
      This instance must be tagged as PathOrLink.Tag.LINK.
      Returns:
      The SharedLinkFileInfo value associated with this instance if isLink() is true.
      Throws:
      IllegalStateException - If isLink() is false.
    • isOther

      public boolean isOther()
      Returns true if this instance has the tag PathOrLink.Tag.OTHER, false otherwise.
      Returns:
      true if this instance is tagged as PathOrLink.Tag.OTHER, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toStringMultiline

      public String toStringMultiline()
      Returns a String representation of this object formatted for easier readability.

      The returned String may contain newlines.

      Returns:
      Formatted, multiline String representation of this object