Class ResourcePath
- java.lang.Object
-
- com.inductiveautomation.ignition.common.project.resource.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 Summary
Constructors Constructor Description ResourcePath(ResourceType type, StringPath path)
ResourcePath(ResourceType type, java.lang.String path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ResourcePath that)
static ResourcePath
createModuleRoot(java.lang.String moduleId)
boolean
equals(java.lang.Object o)
ResourcePath
getChild(java.lang.String... pathParts)
java.lang.String
getFolderPath()
Returns a string version of the path of this resource.java.lang.String
getModuleId()
java.lang.String
getName()
ResourcePath
getParent()
java.lang.String
getParentPath()
StringPath.CaseSensitiveStringPath
getPath()
ResourceType
getResourceType()
java.lang.String
getType()
int
hashCode()
boolean
isAncestorOf(ResourcePath possibleDescendant)
Returnstrue
if this ResourcePath is an ancestor ofpossibleDescendant
.boolean
isModuleFolder()
Returnstrue
if this ResourcePath points to a module's root folder.boolean
isParentOf(ResourcePath possibleChild)
boolean
isResourceTypeFolder()
Returnstrue
if this ResourcePath points to a resource type folder.java.lang.String
toString()
-
-
-
Constructor Detail
-
ResourcePath
public ResourcePath(@Nonnull ResourceType type, @Nullable java.lang.String path)
- Parameters:
type
- the type of resourcepath
- 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 resourcepath
- 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)
-
getResourceType
public ResourceType getResourceType()
-
isModuleFolder
public boolean isModuleFolder()
Returnstrue
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()
Returnstrue
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 ofpossibleChild
.
-
isAncestorOf
public boolean isAncestorOf(ResourcePath possibleDescendant)
Returnstrue
if this ResourcePath is an ancestor ofpossibleDescendant
.- Parameters:
possibleDescendant
- the ResourcePath that might be a descendant.- Returns:
true
if this ResourcePath is an ancestor ofpossibleDescendant
.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the full path represented by this resourcePath
-
getModuleId
public java.lang.String getModuleId()
-
getType
public java.lang.String getType()
-
getPath
@Nonnull public StringPath.CaseSensitiveStringPath getPath()
- Returns:
- the path after the resource type. Includes the resource name
-
getFolderPath
public java.lang.String getFolderPath()
Returns a string version of the path of this resource.
-
getParentPath
public java.lang.String getParentPath()
-
getParent
public ResourcePath getParent()
-
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 interfacejava.lang.Comparable<ResourcePath>
-
-