public class EntityReference extends Object implements Serializable, Cloneable, Comparable<EntityReference>
| Modifier and Type | Field and Description |
|---|---|
protected static org.xwiki.model.internal.reference.LocalizedStringEntityReferenceSerializer |
TOSTRING_SERIALIZER
Used to provide a nice and readable pretty name for the
toString() method. |
| Modifier | Constructor and Description |
|---|---|
|
EntityReference(EntityReference reference)
Clone an EntityReference.
|
|
EntityReference(EntityReference reference,
EntityReference parent)
Clone an EntityReference, but use the specified parent for its new parent.
|
protected |
EntityReference(EntityReference reference,
EntityReference oldReference,
EntityReference newReference)
Clone an EntityReference, but replace one of the parent in the chain by an other one.
|
|
EntityReference(String name,
EntityType type)
Create a new root EntityReference.
|
|
EntityReference(String name,
EntityType type,
EntityReference parent)
Create a new EntityReference.
|
protected |
EntityReference(String name,
EntityType type,
EntityReference parent,
Map<String,Serializable> parameters)
Create a new EntityReference.
|
| Modifier and Type | Method and Description |
|---|---|
EntityReference |
appendParent(EntityReference newParent)
Return a clone of this reference with a parent appended at the root of its parents chain.
|
int |
compareTo(EntityReference reference) |
boolean |
equals(Object obj) |
EntityReference |
extractReference(EntityType type)
Extract the entity of the given type from this one.
|
String |
getName()
Returns the name of this entity.
|
protected <T> T |
getParameter(String name)
Get the value of a parameter.
|
EntityReference |
getParent() |
List<EntityReference> |
getReversedReferenceChain() |
EntityReference |
getRoot() |
EntityType |
getType()
Returns the type of this entity.
|
int |
hashCode() |
EntityReference |
removeParent(EntityReference oldParent)
Return a clone of this reference truncated to a null parent when it reach the given parent.
|
EntityReference |
replaceParent(EntityReference oldParent,
EntityReference newParent)
Return a clone of this reference, but with one of its parent replaced by another one.
|
protected void |
setName(String name)
Entity reference are immutable since 3.3M2, so this method is now protected.
|
protected void |
setParameter(String name,
Serializable value)
Add or set a parameter value.
|
protected void |
setParameters(Map<String,Serializable> parameters)
Set multiple parameters at once.
|
protected void |
setParent(EntityReference parent)
Entity reference are immutable since 3.3M2, so this method is now protected.
|
protected void |
setType(EntityType type)
Entity reference are immutable since 3.3M2, so this method is now protected.
|
String |
toString() |
protected static final org.xwiki.model.internal.reference.LocalizedStringEntityReferenceSerializer TOSTRING_SERIALIZER
toString() method.public EntityReference(EntityReference reference)
reference - the reference to clonepublic EntityReference(EntityReference reference, EntityReference parent)
reference - the reference to cloneparent - the new parent to useprotected EntityReference(EntityReference reference, EntityReference oldReference, EntityReference newReference)
reference - the reference that is clonedoldReference - the old parent that will be replacednewReference - the new parent that will replace oldReference in the chainpublic EntityReference(String name, EntityType type)
name - name for the newly created entity reference, could not be null.type - type for the newly created entity reference, could not be null.public EntityReference(String name, EntityType type, EntityReference parent)
name - name for the newly created entity reference, could not be null.type - type for the newly created entity reference, could not be null.parent - parent reference for the newly created entity reference, may be null.protected EntityReference(String name, EntityType type, EntityReference parent, Map<String,Serializable> parameters)
name - name for the newly created entity, could not be null.type - type for the newly created entity, could not be null.parent - parent reference for the newly created entity reference, may be null.parameters - parameters for this reference, may be nullprotected void setName(String name)
name - the name for this entityIllegalArgumentException - if the passed name is null or emptypublic final String getName()
protected void setParent(EntityReference parent)
parent - the parent for this entity, may be null for a root entity.public final EntityReference getParent()
protected void setType(EntityType type)
type - the type for this entityIllegalArgumentException - if the passed type is nullpublic final EntityType getType()
protected void setParameters(Map<String,Serializable> parameters)
parameters - the map of parameter to setprotected void setParameter(String name, Serializable value)
name - the name of the parametervalue - the value of the parameterprotected final <T> T getParameter(String name)
T - the type of the value of the requested parametername - the name of the parameter to getpublic EntityReference getRoot()
public List<EntityReference> getReversedReferenceChain()
public EntityReference extractReference(EntityType type)
type - the type of the entity to be extractedpublic EntityReference replaceParent(EntityReference oldParent, EntityReference newParent)
oldParent - the old parent that will be replacednewParent - the new parent that will replace oldParent in the chain. If the same as oldParent,
this is returned.public EntityReference appendParent(EntityReference newParent)
newParent - the parent that became the root parent of this reference (and its parent).
If null, this is returned.public EntityReference removeParent(EntityReference oldParent)
oldParent - the parent that will be replaced by a null. If null, this is returned.public int compareTo(EntityReference reference)
compareTo in interface Comparable<EntityReference>Copyright © 2004–2014 XWiki. All rights reserved.