ReferenceValue
- public class ReferenceValue implements SingleValue
A ReferenceValue represents the value of a reference property to another entity.
Differently from other properties, they may be versioned, i.e. they may reference to a specific version of an entity.
Ways to specify a reference value: {id}@{version} using either the version id (a hex’ed sha256 string) or “HEAD”, “HEAD~1”, “HEAD~2” and so on. Note: “HEAD” always means the “HEAD” after the transaction. So, if you are changing the referenced entity in the same transaction and you want to reference the entity in the version before the change you need to use “HEAD~1” because that is the old version of the future.
- Author:
Timm Fitschen
Constructors
ReferenceValue
- public ReferenceValue(EntityInterface entity, boolean versioned)
ReferenceValue
ReferenceValue
ReferenceValue
ReferenceValue
Methods
addToElement
- public void addToElement(Element e)
equals
equals
getEntity
- public final EntityInterface getEntity()
getId
getIdVersion
getName
getTable
getVersion
parseFromString
- public static ReferenceValue parseFromString(String str)
Create a ReferenceValue from a string.
If the string looks like a valid “entityID@version” string, the result will have the corresponding entity and version parts.
parseIdVersion
- public static ReferenceValue parseIdVersion(String str)
Split a reference string into an entity part and a version part, if there is a version part.
If parsing the entity ID part to an integer fails, a NumberFormatException may be thrown.
parseReference
- public static ReferenceValue parseReference(EntityID reference)
parseReference
- public static ReferenceValue parseReference(Object reference)
setEntity
- public final void setEntity(EntityInterface entity, boolean versioned)
setId
setName
toDatabaseString
toString
- public String toString()
Produce a nice but short string:
Case 1 “versioned” (reference to an entity without specifying that entity’s version): Produces a string like “1234” or “Experiment”. Note that referencing via name is never versioned.
Case 2 “unversioned” (reference to an entity with a specified version): Produces a string like “1234@ab987f”.