Package org.opencms.relations
Class CmsRelation
- java.lang.Object
-
- org.opencms.relations.CmsRelation
-
public class CmsRelation extends java.lang.Object
A relation between two opencms resources.- Since:
- 6.3.0
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<CmsRelation>
COMPARATOR
A comparator for the source & target path plus the relation type of 2 relations.
-
Constructor Summary
Constructors Constructor Description CmsRelation(CmsResource source, CmsResource target, CmsRelationType type)
Creates a new relation object of the given type between the given resources.CmsRelation(CmsUUID sourceId, java.lang.String sourcePath, CmsUUID targetId, java.lang.String targetPath, CmsRelationType type)
Base constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
CmsResource
getSource(CmsObject cms, CmsResourceFilter filter)
Returns the source resource when possible to read with the given filter.CmsUUID
getSourceId()
Returns the structure id of the source resource.java.lang.String
getSourcePath()
Returns the path of the source resource.CmsResource
getTarget(CmsObject cms, CmsResourceFilter filter)
Returns the target resource when possible to read with the given filter.CmsUUID
getTargetId()
Returns the structure id of the target resource.java.lang.String
getTargetPath()
Returns the path of the target resource.CmsRelationType
getType()
Returns the relation type.int
hashCode()
java.lang.String
toString()
CmsRelation
withTargetId(CmsUUID id)
Copies this relation, but sets the target id in the copy to the given value.
-
-
-
Field Detail
-
COMPARATOR
public static final java.util.Comparator<CmsRelation> COMPARATOR
A comparator for the source & target path plus the relation type of 2 relations.
-
-
Constructor Detail
-
CmsRelation
public CmsRelation(CmsResource source, CmsResource target, CmsRelationType type)
Creates a new relation object of the given type between the given resources.- Parameters:
source
- the source resourcetarget
- the target resourcetype
- the relation type
-
CmsRelation
public CmsRelation(CmsUUID sourceId, java.lang.String sourcePath, CmsUUID targetId, java.lang.String targetPath, CmsRelationType type)
Base constructor.- Parameters:
sourceId
- the source structure idsourcePath
- the source pathtargetId
- the target structure idtargetPath
- the target pathtype
- the relation type
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getSource
public CmsResource getSource(CmsObject cms, CmsResourceFilter filter) throws CmsException
Returns the source resource when possible to read with the given filter.- Parameters:
cms
- the current user contextfilter
- the filter to use- Returns:
- the source resource
- Throws:
CmsException
- if something goes wrong
-
getSourceId
public CmsUUID getSourceId()
Returns the structure id of the source resource.- Returns:
- the structure id of the source resource
-
getSourcePath
public java.lang.String getSourcePath()
Returns the path of the source resource.- Returns:
- the path of the source resource
-
getTarget
public CmsResource getTarget(CmsObject cms, CmsResourceFilter filter) throws CmsException
Returns the target resource when possible to read with the given filter.- Parameters:
cms
- the current user contextfilter
- the filter to use- Returns:
- the target resource
- Throws:
CmsException
- if something goes wrong
-
getTargetId
public CmsUUID getTargetId()
Returns the structure id of the target resource.- Returns:
- the structure id of the target resource
-
getTargetPath
public java.lang.String getTargetPath()
Returns the path of the target resource.- Returns:
- the path of the target resource
-
getType
public CmsRelationType getType()
Returns the relation type.- Returns:
- the relation type
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
withTargetId
public CmsRelation withTargetId(CmsUUID id)
Copies this relation, but sets the target id in the copy to the given value.- Parameters:
id
- the new target id for the copy- Returns:
- the copy with the target id
-
-