Interface ResourceEntry

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
AbstractResourceEntry, NullResourceEntry, UnixFSResourceEntryBase, UnixFSResourceEntryExisting, UnixFSResourceEntryNew

public interface ResourceEntry extends AutoCloseable
Represents a node in the Snapshot. A Node contains all the known information of a Resource.
  • Method Details

    • isPresent

      default boolean isPresent()
      Returns true if the entry represents a present entry.
      Returns:
      true if nascent, false otherwise
    • isAbsent

      default boolean isAbsent()
      Returns true if the entry represents an absent entry.
      Returns:
      true if absent, false otherwise
    • isOriginalContents

      boolean isOriginalContents()
      Return true if the content is the original content.
      Returns:
      true if the content is original.
    • isOriginalReversePaths

      boolean isOriginalReversePaths()
      Checks if the list of reverse links are the original set of reverse links.
      Returns:
      true if the links are original
    • getResourceId

      default ResourceId getResourceId()
      Gets the ResourceId or throws an instance of ResourceNotFoundException if no such resource exists with this entry.
      Returns:
      the ResourceId, never null
    • getOriginalResourceId

      default ResourceId getOriginalResourceId()
      Gets the ResourceId or throws an instance of ResourceNotFoundException if no such resource exists with this entry.
      Returns:
      the ResourceId, never null
    • findResourceId

      Optional<ResourceId> findResourceId()
      Finds the ResourceId associated with the node, or a result equivalent to Optional.empty() if no such resource id exists.
      Returns:
      an Optional<ResourceId> containing the ResourceId
    • findOriginalResourceId

      default Optional<ResourceId> findOriginalResourceId()
      Finds the ResourceId associated with the node, or a result equivalent to Optional.empty() if no such resource id exists.
      Returns:
      an Optional<ResourceId> containing the ResourceId
    • getReversePathsImmutable

      Set<Path> getReversePathsImmutable()
      Gets the internal immutable list of reverse links. Will always return an empty Set if no links exist.
      Returns:
      the reverse links, never null.
    • getOriginalReversePathsImmutable

      default Set<Path> getOriginalReversePathsImmutable()
      Gets the internal immutable list of reverse links. Will always return an empty Set if no links exist.
      Returns:
      the reverse links, never null.
    • loadResourceContents

      default ReadableByteChannel loadResourceContents() throws IOException, NullResourceException
      Loads the byte contents of the resource.
      Returns:
      the contents as a ReadableByteChannel
      Throws:
      NullResourceException - if no contents exist for the resource.
      IOException
    • findResourceContents

      default Optional<ResourceContents> findResourceContents()
      Finds the Resource contents.
      Returns:
      the Optional of ResourceContents
    • findOriginalResourceContents

      default Optional<ResourceContents> findOriginalResourceContents()
      Finds the original Resource contents.
      Returns:
      the Optional of ResourceContents
    • link

      boolean link(Path path)
      Links this ResourceEntry for the supplied Path.
      Parameters:
      path - the Path to unlink
      Returns:
      Throws:
      DuplicateException - if the entry is present at path
      IllegalArgumentException - if the Path is a wildcard path
      SnapshotMissException - if the supplied Path is not in the current snapshot entry
    • unlink

      boolean unlink(Path path)
      Unlinks this ResourceEntry for the supplied Path.
      Parameters:
      path - the Path to unlink
      Returns:
      true if the collection changed as the result of this operation
      Throws:
      IllegalStateException - if the entry is nascent
      SnapshotMissException - if the supplied Path is not in the current snapshot entry
    • updateResourceContents

      ResourceContents updateResourceContents()
      Updates the contents of this ResourceEntry by overriding the supplied
      Returns:
      ResourceContents the contents
    • delete

      boolean delete()
      Flags this entry for removal returning the entry to absent state. If this entry is absent this will have no effect and the method will return false. Additionally, the operational strategy associated with this entry may opt to do nothing and return false as well.
      Returns:
      true if clearing this entry had any effect
    • flush

      void flush(TransactionJournal.MutableEntry mutableEntry)
      Flushes a copy of this ResourceEntry to storage, identified with the supplied transaction ID.
      Parameters:
      mutableEntry - the transaction id
    • close

      default void close()
      Closers this ResourceEntry releasing any underlying resources associated with the ResourceEntry.
      Specified by:
      close in interface AutoCloseable