Class ResourcePath

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ResourcePath>

    public class ResourcePath
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<ResourcePath>
    Represents a full resource path from the file system, relative to a Project.

    Takes the form of moduleId[/resourceType[/path]]

    See Also:
    Serialized Form
    • Constructor Detail

      • ResourcePath

        public ResourcePath​(@Nonnull
                            ResourceType type,
                            @Nullable
                            java.lang.String path)
        Parameters:
        type - the type of resource
        path - the full path underneath the resource type folder, ending with the name of the resource.
      • ResourcePath

        public ResourcePath​(@Nonnull
                            ResourceType type,
                            @Nonnull
                            StringPath path)
        Parameters:
        type - the type of resource
        path - the full path underneath the resource type folder, ending with the name of the resource.
    • Method Detail

      • createModuleRoot

        public static ResourcePath createModuleRoot​(java.lang.String moduleId)
      • isModuleFolder

        public boolean isModuleFolder()
        Returns true if this ResourcePath points to a module's root folder.

        This means that the path is root (StringPath.isRoot() and the ResourceType's typeId is null.

        Returns:
        true if this ResourcePath points to a module's root folder.
      • isResourceTypeFolder

        public boolean isResourceTypeFolder()
        Returns true if this ResourcePath points to a resource type folder.
        Returns:
        true if this ResourcePath points to a resource type folder.
      • isParentOf

        public boolean isParentOf​(ResourcePath possibleChild)
        Returns:
        true if this ResourcePath is the direct parent of possibleChild.
      • isAncestorOf

        public boolean isAncestorOf​(ResourcePath possibleDescendant)
        Returns true if this ResourcePath is an ancestor of possibleDescendant.
        Parameters:
        possibleDescendant - the ResourcePath that might be a descendant.
        Returns:
        true if this ResourcePath is an ancestor of possibleDescendant.
      • hashCode

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

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        the full path represented by this resourcePath
      • getModuleId

        public java.lang.String getModuleId()
      • getType

        public java.lang.String getType()
      • getFolderPath

        public java.lang.String getFolderPath()
        Returns a string version of the path of this resource.
      • getParentPath

        public java.lang.String getParentPath()
      • getChild

        public ResourcePath getChild​(java.lang.String... pathParts)
      • getName

        public java.lang.String getName()
        Returns:
        the name that identifies the resource. Either the last element of the path, or the resourceType if the types folder, or the moduleId if the modules folder.
      • compareTo

        public int compareTo​(@Nonnull
                             ResourcePath that)
        Specified by:
        compareTo in interface java.lang.Comparable<ResourcePath>