public class EntityBuilder extends Object
EntityBuilder
provides a programmatic interface to performing assertions on a specific entity.
It provides functions for adding and retracting values for attributes for an entity within
an in progress transaction.
The `transact` function will transact the assertions that have been added to the EntityBuilder
and pass back the TxReport
that was generated by this transact and the InProgress
that was
used to perform the transact. This enables you to perform further transacts on the same InProgress
before committing.
long aEntid = txReport.getEntidForTempId("a");
long bEntid = txReport.getEntidForTempId("b");
EntityBuilder builder = mentat.getEntityBuilderForEntid(bEntid);
builder.add(":foo/boolean", true);
builder.add(":foo/instant", newDate);
InProgress inProgress = builder.transact().getInProgress();
inProgress.transact("[[:db/add \(aEntid) :foo/long 22]]");
inProgress.commit();
The `commit` function will transact and commit the assertions that have been added to the EntityBuilder
.
It will consume the InProgress
used to perform the transact. It returns the TxReport
generated by
the transact. After calling `commit`, a new transaction must be started by calling Mentat.beginTransaction()in order to perform further actions.
long aEntid = txReport.getEntidForTempId("a");
EntityBuilder builder = mentat.getEntityBuilderForEntid(bEntid);
builder.add(":foo/boolean", true);
builder.add(":foo/instant", newDate);
builder.commit();
Constructor and Description |
---|
EntityBuilder(com.sun.jna.Pointer pointer) |
Modifier and Type | Method and Description |
---|---|
void |
add(String keyword,
boolean value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
add(String keyword,
Date value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
add(String keyword,
double value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
add(String keyword,
long value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
add(String keyword,
String value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
add(String keyword,
UUID value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
addKeyword(String keyword,
String value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
addRef(String keyword,
long value)
Asserts the value of attribute `keyword` to be the provided `value`.
|
void |
close() |
TxReport |
commit()
Transacts the added assertions and commits.
|
com.sun.jna.Pointer |
getPointerForUUID(UUID uuid) |
UUID |
getUUIDFromPointer(com.sun.jna.Pointer uuidPtr) |
void |
retract(String keyword,
boolean value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retract(String keyword,
Date value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retract(String keyword,
double value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retract(String keyword,
long value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retract(String keyword,
String value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retract(String keyword,
UUID value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retractKeyword(String keyword,
String value)
Retracts the value of attribute `keyword` from the provided `value`.
|
void |
retractRef(String keyword,
long value)
Retracts the value of attribute `keyword` from the provided `value`.
|
InProgressTransactionResult |
transact()
Transacts the added assertions.
|
public void add(String keyword, long value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void addRef(String keyword, long value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void addKeyword(String keyword, String value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void add(String keyword, boolean value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void add(String keyword, double value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void add(String keyword, Date value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void add(String keyword, String value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void add(String keyword, UUID value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be assertedpublic void retract(String keyword, long value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retractRef(String keyword, long value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retractKeyword(String keyword, String value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retract(String keyword, boolean value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retract(String keyword, double value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retract(String keyword, Date value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retract(String keyword, String value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic void retract(String keyword, UUID value)
keyword
- The name of the attribute in the format `:namespace/name`.value
- The value to be retractedpublic InProgressTransactionResult transact()
EntityBuilder
such that no further assertions can be added after the `transact` has completed. To perform
further assertions, use the InProgress
inside the InProgressTransactionResult
returned from this function.
This does not commit the transaction. In order to do so, `commit` can be called on the
InProgress
inside the InProgressTransactionResult
returned from this function.
TODO throw exception if error occursInProgressTransactionResult
containing the current InProgress
and
the TxReport
generated by the transact.public TxReport commit()
EntityBuilder
and the associated InProgress
such that no further assertions
can be added after the `commit` has completed.
To perform further assertions, a new `InProgress
or EntityBuilder
should be
created.
TODO throw exception if error occursTxReport
generated by the commit.public void close() throws IOException
IOException
public com.sun.jna.Pointer getPointerForUUID(UUID uuid)
public UUID getUUIDFromPointer(com.sun.jna.Pointer uuidPtr)