java.lang.Object
com.inductiveautomation.ignition.common.project.resource.ResourcePath
All Implemented Interfaces:
Serializable, Comparable<ResourcePath>

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

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

See Also:
  • Constructor Details

    • ResourcePath

      public ResourcePath(@Nonnull ResourceType type, @Nullable 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 Details

    • createModuleRoot

      public static ResourcePath createModuleRoot(String moduleId)
    • getResourceType

      public ResourceType getResourceType()
    • 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 Object
    • equals

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

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

      public String getModuleId()
    • getType

      public String getType()
    • getPath

      @Nonnull public StringPath.CaseSensitiveStringPath getPath()
      Returns:
      the path after the resource type. Includes the resource name
    • getFolderPath

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

      public String getParentPath()
    • getParent

      public ResourcePath getParent()
    • getChild

      public ResourcePath getChild(String... pathParts)
    • getName

      public 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 Comparable<ResourcePath>