Interface Remote

All Superinterfaces:
SourceFile, Tree
All Known Implementing Classes:
RemoteArchive, RemoteFile

public interface Remote extends SourceFile
Represents a source hosted at a remote URI.

Downloading the remote file is not handled during Recipe execution. Post-processing of Recipe results by a build plugin or other caller of OpenRewrite is responsible for this.

Metadata like Charset or FileAttributes are supplied by the Recipe creating the Remote so that when the file is later downloaded it can be configured correctly. If no Charset is configured the downloaded file will be interpreted as binary data. If no FileAttributes are set the downloaded file will be marked as readable and writable but not executable. If a Checksum is provided it will be used to validate the integrity of the downloaded file.

  • Method Details

    • getUri

      URI getUri()
    • withUri

      <R extends Remote> R withUri(URI uri)
    • getDescription

      String getDescription()
      Any text describing what this remote URI represents. Used to present human-readable results to an end user.
    • withDescription

      <R extends Remote> R withDescription(String description)
    • getChecksum

      @Nullable default @Nullable Checksum getChecksum()
      Specified by:
      getChecksum in interface SourceFile
    • withChecksum

      default <T extends SourceFile> T withChecksum(@Nullable @Nullable Checksum checksum)
      Specified by:
      withChecksum in interface SourceFile
    • getInputStream

      InputStream getInputStream(ExecutionContext ctx)
      Download the remote file
      Parameters:
      ctx - used to download the file represented by this Remote
    • printAll

      default <P> String printAll(P p)
      Specified by:
      printAll in interface SourceFile
    • printAllTrimmed

      default <P> String printAllTrimmed(P p)
      Specified by:
      printAllTrimmed in interface SourceFile
    • accept

      default <R extends Tree, P> R accept(TreeVisitor<R,P> v, P p)
      Description copied from interface: Tree
      Supports polymorphic visiting via TreeVisitor.visit(Tree, Object). This is useful in cases where an AST type contains a field that is of a type with a hierarchy. The visitor doesn't have to figure out which visit method to call by using instanceof.
      Specified by:
      accept in interface Tree
      Type Parameters:
      R - visitor return type
      P - visit context type
      Parameters:
      v - visitor
      p - visit context
      Returns:
      visitor result
    • isAcceptable

      default <P> boolean isAcceptable(TreeVisitor<?,P> v, P p)
      Description copied from interface: Tree
      Checks the supplied argument to see if the supplied visitor and its context would be valid arguments to accept(). Typically, this involves checking that the visitor is of a type that operates on this kind of tree. e.g.: A Java Tree implementation would return true for JavaVisitors and false for MavenVisitors
      Specified by:
      isAcceptable in interface Tree
      Type Parameters:
      P - the visitor's context argument
      Returns:
      'true' if the arguments to this function would be valid arguments to accept()
    • builder

      static Remote.Builder builder(SourceFile before, URI uri)
    • builder

      static Remote.Builder builder(Path sourcePath, URI uri)
    • builder

      static Remote.Builder builder(UUID id, Path sourcePath, Markers markers, URI uri)
    • printer

      default <P> TreeVisitor<?,PrintOutputCapture<P>> printer(Cursor cursor)
      Specified by:
      printer in interface SourceFile
      Specified by:
      printer in interface Tree