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 intcompareTo(ResourcePath that)static ResourcePathcreateModuleRoot(java.lang.String moduleId)booleanequals(java.lang.Object o)ResourcePathgetChild(java.lang.String... pathParts)java.lang.StringgetFolderPath()Returns a string version of the path of this resource.java.lang.StringgetModuleId()java.lang.StringgetName()ResourcePathgetParent()java.lang.StringgetParentPath()StringPath.CaseSensitiveStringPathgetPath()ResourceTypegetResourceType()java.lang.StringgetType()inthashCode()booleanisAncestorOf(ResourcePath possibleDescendant)Returnstrueif this ResourcePath is an ancestor ofpossibleDescendant.booleanisModuleFolder()Returnstrueif this ResourcePath points to a module's root folder.booleanisParentOf(ResourcePath possibleChild)booleanisResourceTypeFolder()Returnstrueif this ResourcePath points to a resource type folder.java.lang.StringtoString()
-
-
-
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()
Returnstrueif 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:
trueif this ResourcePath points to a module's root folder.
-
isResourceTypeFolder
public boolean isResourceTypeFolder()
Returnstrueif this ResourcePath points to a resource type folder.- Returns:
trueif this ResourcePath points to a resource type folder.
-
isParentOf
public boolean isParentOf(ResourcePath possibleChild)
- Returns:
trueif this ResourcePath is the direct parent ofpossibleChild.
-
isAncestorOf
public boolean isAncestorOf(ResourcePath possibleDescendant)
Returnstrueif this ResourcePath is an ancestor ofpossibleDescendant.- Parameters:
possibleDescendant- the ResourcePath that might be a descendant.- Returns:
trueif this ResourcePath is an ancestor ofpossibleDescendant.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
compareToin interfacejava.lang.Comparable<ResourcePath>
-
-