public interface Entity extends java.lang.Comparable<Entity>
Entity is an object in the EntityStore. Any Entity has type and
unique id. Entity can have properties and
blobs, and can be linked. Each property, blob or link
is identified by its name. Although entity properties are expected to be Comparable, only Java primitives
types, Strings and ComparableSet values can
be used by default. Use registerCustomPropertyType() to define your own property type.
To create new entity, use StoreTransaction.newEntity(String):
final Entity user = txn.newEntity("User");
To get unique if of and entity, use getId():
final EntityId id = user.getId();
To get existing entity by id, use StoreTransaction.getEntity(EntityId):
final Entity user = txn.getEntity(id);
EntityStore,
EntityId,
StoreTransaction| Modifier and Type | Method and Description |
|---|---|
boolean |
addLink(@NotNull java.lang.String linkName,
@NotNull Entity target)
Adds link with specified name from this entity to specified entity.
|
boolean |
addLink(@NotNull java.lang.String linkName,
@NotNull EntityId targetId)
Adds link with specified name from this entity to an entity with specified id.
|
boolean |
delete()
Deletes the entity unconditionally.
|
boolean |
deleteBlob(@NotNull java.lang.String blobName)
Deletes blob with specified name.
|
boolean |
deleteLink(@NotNull java.lang.String linkName,
@NotNull Entity target)
Deletes the link with specified name to specified target.
|
boolean |
deleteLink(@NotNull java.lang.String linkName,
@NotNull EntityId targetId)
Deletes the link with specified name to target with specified id.
|
void |
deleteLinks(@NotNull java.lang.String linkName)
Deletes links to all entities which this entity is linked by the link with specified name.
|
boolean |
deleteProperty(@NotNull java.lang.String propertyName)
Deletes property with specified name.
|
@Nullable java.io.InputStream |
getBlob(@NotNull java.lang.String blobName)
Gets value of blob with specified name as InputStream.
|
@NotNull java.util.List<java.lang.String> |
getBlobNames()
Returns names of all blobs of the entity.
|
long |
getBlobSize(@NotNull java.lang.String blobName)
Gets the size of blob with specified name.
|
@Nullable java.lang.String |
getBlobString(@NotNull java.lang.String blobName)
Gets value of blob with specified name as
UTF8-encoded string.
|
@NotNull EntityId |
getId() |
@Nullable Entity |
getLink(@NotNull java.lang.String linkName)
Returns a single entity which this one is linked by link with specified name, or
null
if no such entity exists. |
@NotNull java.util.List<java.lang.String> |
getLinkNames()
Returns names of all links of the entity.
|
@NotNull EntityIterable |
getLinks(@NotNull java.util.Collection<java.lang.String> linkNames)
Returns all entities which this one is linked by links with specified names.
|
@NotNull EntityIterable |
getLinks(@NotNull java.lang.String linkName)
Returns all entities which this one is linked by the link with specified name.
|
@Nullable java.lang.Comparable |
getProperty(@NotNull java.lang.String propertyName)
Gets value of property with specified name.
|
@NotNull java.util.List<java.lang.String> |
getPropertyNames()
Returns names of all properties of the entity.
|
@Nullable ByteIterable |
getRawProperty(@NotNull java.lang.String propertyName)
Gets raw value of the property with specified name.
|
@NotNull EntityStore |
getStore() |
@NotNull java.lang.String |
getType() |
void |
setBlob(@NotNull java.lang.String blobName,
@NotNull java.io.File file)
Sets value (as contents of File) of blob with specified name.
|
void |
setBlob(@NotNull java.lang.String blobName,
@NotNull java.io.InputStream blob)
Sets value (as InputStream) of blob with specified name.
|
boolean |
setBlobString(@NotNull java.lang.String blobName,
@NotNull java.lang.String blobString)
Sets value (as String encoded in UTF-8) of blob with specified name.
|
boolean |
setLink(@NotNull java.lang.String linkName,
@Nullable Entity target)
Links this entity with target one by link with specified name.
|
boolean |
setLink(@NotNull java.lang.String linkName,
@NotNull EntityId targetId)
Links this entity with target with specified id by link with specified name.
|
boolean |
setProperty(@NotNull java.lang.String propertyName,
@NotNull java.lang.Comparable value)
Sets property with specified name to specified value.
|
@NotNull java.lang.String |
toIdString() |
@NotNull @NotNull EntityStore getStore()
@NotNull @NotNull java.lang.String toIdString()
StoreTransaction.toEntityId(String)@NotNull @NotNull java.lang.String getType()
boolean delete()
true if the entity was deleted, otherwise it didn't exist@Nullable @Nullable ByteIterable getRawProperty(@NotNull @NotNull java.lang.String propertyName)
propertyName - name of the propertynull if the property is not setByteIterable,
getProperty(String),
setProperty(String, Comparable),
deleteProperty(String),
getPropertyNames()@Nullable
@Nullable java.lang.Comparable getProperty(@NotNull
@NotNull java.lang.String propertyName)
propertyName - name of the propertynull if the property is not setgetRawProperty(String),
setProperty(String, Comparable),
deleteProperty(String),
getPropertyNames()boolean setProperty(@NotNull
@NotNull java.lang.String propertyName,
@NotNull
@NotNull java.lang.Comparable value)
false,
it is the same as calling deleteProperty(String).propertyName - name of the propertyvalue - property valuetrue if value was actually set, i.e. if it is not equal to the old valuegetProperty(String),
getRawProperty(String),
deleteProperty(String),
getPropertyNames()boolean deleteProperty(@NotNull
@NotNull java.lang.String propertyName)
propertyName - name of the propertytrue if the property was actually deleted, otherwise it didn't existgetProperty(String),
getRawProperty(String),
setProperty(String, Comparable),
getPropertyNames()@NotNull @NotNull java.util.List<java.lang.String> getPropertyNames()
getProperty(String),
getRawProperty(String),
setProperty(String, Comparable),
deleteProperty(String)@Nullable
@Nullable java.io.InputStream getBlob(@NotNull
@NotNull java.lang.String blobName)
blobName - name of the blobnull if the blob is not setgetBlobSize(String),
getBlobString(String),
setBlob(String, InputStream),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String)long getBlobSize(@NotNull
@NotNull java.lang.String blobName)
blobName - name of the blobgetBlob(String),
getBlobString(String),
setBlob(String, InputStream),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String)@Nullable
@Nullable java.lang.String getBlobString(@NotNull
@NotNull java.lang.String blobName)
blobName - name of the blobnull if the blob is not setgetBlob(String),
getBlobSize(String),
UTFUtil.readUTF(InputStream),
setBlob(String, InputStream),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String)void setBlob(@NotNull
@NotNull java.lang.String blobName,
@NotNull
@NotNull java.io.InputStream blob)
blobName - name of the blobblob - blob value as InputStreamgetBlob(String),
getBlobSize(String),
getBlobString(String),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String),
PersistentEntityStoreConfig.getMaxInPlaceBlobSize()void setBlob(@NotNull
@NotNull java.lang.String blobName,
@NotNull
@NotNull java.io.File file)
file exists on a common physical
partition) it can succeed by just renaming the file instead of copying.blobName - name of the blobfile - blob value as InputStreamgetBlob(String),
getBlobSize(String),
getBlobString(String),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String),
PersistentEntityStoreConfig.getMaxInPlaceBlobSize()boolean setBlobString(@NotNull
@NotNull java.lang.String blobName,
@NotNull
@NotNull java.lang.String blobString)
blobName - name of the blobblobString - blob valuetrue if blobString is not equal to old valuegetBlob(String),
getBlobSize(String),
getBlobString(String),
UTFUtil.readUTF(InputStream),
setBlob(String, InputStream),
setBlob(String, File),
deleteBlob(String)boolean deleteBlob(@NotNull
@NotNull java.lang.String blobName)
blobName - name of the blobtrue if the blob was actually deleted, otherwise it didn't existgetBlob(String),
getBlobSize(String),
getBlobString(String),
setBlob(String, InputStream),
setBlob(String, File),
setBlobString(String, String)@NotNull @NotNull java.util.List<java.lang.String> getBlobNames()
getBlob(String),
getBlobSize(String),
getBlobString(String),
setBlob(String, InputStream),
setBlob(String, File),
setBlobString(String, String),
deleteBlob(String)boolean addLink(@NotNull
@NotNull java.lang.String linkName,
@NotNull
@NotNull Entity target)
linkName - name of the linktarget - entity to link withtrue if the link didn't existaddLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()boolean addLink(@NotNull
@NotNull java.lang.String linkName,
@NotNull
@NotNull EntityId targetId)
false.linkName - name of the linktargetId - id of entity to link withtrue if target exists and the link didn't existaddLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()@Nullable @Nullable Entity getLink(@NotNull @NotNull java.lang.String linkName)
null
if no such entity exists.linkName - name of the linknull if it doesn't existaddLink(String, Entity),
addLink(String, EntityId),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()boolean setLink(@NotNull
@NotNull java.lang.String linkName,
@Nullable
@Nullable Entity target)
linkName - name of the linktarget - entity to link withtrue if target is not equal to old targetaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()boolean setLink(@NotNull
@NotNull java.lang.String linkName,
@NotNull
@NotNull EntityId targetId)
linkName - name of the linktargetId - id of entity to link withtrue if target with specified id exists and is not equal to old targetaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()@NotNull @NotNull EntityIterable getLinks(@NotNull @NotNull java.lang.String linkName)
linkName - name of the linkaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()@NotNull @NotNull EntityIterable getLinks(@NotNull @NotNull java.util.Collection<java.lang.String> linkNames)
linkNames - collection of link namesaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()boolean deleteLink(@NotNull
@NotNull java.lang.String linkName,
@NotNull
@NotNull Entity target)
linkName - name of the linktarget - linked targettrue if the link was actually deleted, otherwise it didn't existaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, EntityId),
deleteLinks(String),
getLinkNames()boolean deleteLink(@NotNull
@NotNull java.lang.String linkName,
@NotNull
@NotNull EntityId targetId)
false.linkName - name of the linktargetId - id of linked targettrue if target with specified id exists and the link was actually deleted, otherwise it didn't existaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLinks(String),
getLinkNames()void deleteLinks(@NotNull
@NotNull java.lang.String linkName)
linkName - name of the linkaddLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
getLinkNames()@NotNull @NotNull java.util.List<java.lang.String> getLinkNames()
addLink(String, Entity),
addLink(String, EntityId),
getLink(String),
getLinks(String),
getLinks(Collection),
setLink(String, Entity),
setLink(String, EntityId),
deleteLink(String, Entity),
deleteLink(String, EntityId),
deleteLinks(String)