Class Location

java.lang.Object
org.flywaydb.core.api.Location
All Implemented Interfaces:
Comparable<Location>

public final class Location extends Object implements Comparable<Location>
A location to load migrations from.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated.
    The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Location(String descriptor)
    Deprecated.
    The Location class should no longer know about possible location types or contain parsing logic.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
     
    static Location
    fromPath(String prefix, String path)
     
    static Location
    fromWildcardPath(String prefix, String rootPath, String wildcardPath, Pattern pathRegex)
     
     
    Deprecated.
    Use the root path instead.
     
    Returns the path relative to this location.
     
    The first folder in the path.
    int
     
    boolean
    Deprecated.
    The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO.
    boolean
    Deprecated.
    The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO.
    boolean
    Deprecated.
    The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO.
    boolean
    Deprecated.
    The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO.
    boolean
    Deprecated.
    This method was previously for internal use by Flyway and is specific to the calling code use case.
    boolean
    Deprecated.
    This method was previously for internal use by Flyway and is specific to the calling code use case.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • fromPath

      public static Location fromPath(String prefix, String path)
    • fromWildcardPath

      public static Location fromWildcardPath(String prefix, String rootPath, String wildcardPath, Pattern pathRegex)
    • matchesPath

      @Deprecated public boolean matchesPath(String path)
      Deprecated.
      This method was previously for internal use by Flyway and is specific to the calling code use case. Usages can be inlined into calling code.
      Returns:
      Whether the given path matches this locations regex. Will always return true when the location did not contain any wildcards.
    • getPathRelativeToThis

      public String getPathRelativeToThis(String path)
      Returns the path relative to this location. If the location path contains wildcards, the returned path will be relative to the last non-wildcard folder in the path.
    • isClassPath

      @Deprecated public boolean isClassPath()
      Deprecated.
      The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO. Calling code ought to know what type of location they are dealing with, or check the prefix directly. Replace with `CoreLocationPrefix.isClassPath(location)`
      Checks whether this denotes a location on the classpath.
      Returns:
      true if it does, false if it doesn't.
    • isFileSystem

      @Deprecated public boolean isFileSystem()
      Deprecated.
      The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO. Calling code ought to know what type of location they are dealing with, or check the prefix directly. Replace with `CoreLocationPrefix.isFileSystem(location)`
      Checks whether this denotes a location on the filesystem.
      Returns:
      true if it does, false if it doesn't.
      See Also:
      • ReadWriteLocationHandler
    • isAwsS3

      @Deprecated public boolean isAwsS3()
      Deprecated.
      The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO. Calling code ought to know what type of location they are dealing with, or check the prefix directly. Replace with `AwsS3LocationHandler.PREFIX.equals(location.getPrefix())` (in flyway-locations-s3 module)
      Checks whether this denotes a location in AWS S3.
      Returns:
      true if it does, false if it doesn't;
      See Also:
      • ReadWriteLocationHandler
    • isGCS

      @Deprecated public boolean isGCS()
      Deprecated.
      The Location class should no longer know about possible location types, which can now be implemented by plugins, and should be treated as a POJO. Calling code ought to know what type of location they are dealing with, or check the prefix directly. Replace with `GcsLocationHandler.PREFIX.equals(location.getPrefix())` (in flyway-locations-gcs module)
      Checks whether this denotes a location in Google cloud storage.
      Returns:
      true if it does, false if it doesn't;
      See Also:
      • ReadWriteLocationHandler
    • isParentOf

      @Deprecated public boolean isParentOf(Location other)
      Deprecated.
      This method was previously for internal use by Flyway and is specific to the calling code use case. The implementation-specific logic can be removed using ReadOnlyLocationHandler.
      Checks whether this location is a parent of this other location.
      Parameters:
      other - The other location.
      Returns:
      true if it is, false if it isn't.
    • getPath

      @Deprecated public String getPath()
      Deprecated.
      Use the root path instead. This path will not be a genuine path for wildcard locations, whereas the root path is always a path.
      Returns:
      The path part of the location.
      See Also:
    • getDescriptor

      public String getDescriptor()
      Returns:
      The complete location descriptor.
    • compareTo

      public int compareTo(Location o)
      Specified by:
      compareTo in interface Comparable<Location>
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      The complete location descriptor.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String getPrefix()
      Returns:
      The prefix part of the location. Can be either classpath: or filesystem:.
    • getRootPath

      public String getRootPath()
      The first folder in the path. This will equal rawPath if the path does not contain any wildcards
      Returns:
      The root part of the path part of the location.
    • getPathRegex

      public Pattern getPathRegex()
      Returns:
      The regex that matches wildcards in the original path. Null if the original path did not contain any wildcards.