Package io.permazen.change
Class Change<T>
java.lang.Object
io.permazen.change.Change<T>
- Type Parameters:
T
- the type of the object that changed
- Direct Known Subclasses:
FieldChange
,ObjectCreate
,ObjectDelete
Object change notification.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
apply()
Apply this change to the transaction associated with the current thread.void
apply
(PermazenObject jobj) Apply this change to the specified object.void
apply
(PermazenTransaction jtx) Apply this change to the object associated with this instance in the given transaction.abstract void
apply
(PermazenTransaction jtx, PermazenObject jobj) Apply this change to the given object in the given transaction.boolean
Get the Java model object containing the field that changed.Get the Java model object containing the field that changed.int
hashCode()
abstract <R> R
visit
(ChangeSwitch<R> target) Apply visitor pattern.
-
Constructor Details
-
Change
Constructor.- Parameters:
jobj
- Java model object that changed- Throws:
IllegalArgumentException
- ifjobj
is null
-
-
Method Details
-
getObject
Get the Java model object containing the field that changed.Although not declared as such to allow flexibility in Java model types, the returned object will always be a
PermazenObject
instance.- Returns:
- the changed object
-
getPermazenObject
Get the Java model object containing the field that changed.This is a convenience method, equivalent to:
(PermazenObject)getObject()
- Returns:
- the changed object as a
PermazenObject
-
visit
Apply visitor pattern. Invokes the method oftarget
corresponding to this instance's type.- Type Parameters:
R
- visitor return type- Parameters:
target
- visitor pattern target- Returns:
- value returned by the selected method of
target
-
apply
Apply this change to the given object in the given transaction.- Parameters:
jobj
- the target object to which to apply this changejtx
- the transaction in which to apply this change- Throws:
DeletedObjectException
- ifjobj
does not exist injtx
UnknownFieldException
- ifjobj
has a schema that does not contain the affected field, or in which the affected field has a different typeRuntimeException
- if there is some other incompatibility between this change and the target object, for example, setting a list element at an index that is out of boundsStaleTransactionException
- ifjtx
is no longer usableIllegalArgumentException
- ifjtx
orjobj
is null
-
apply
Apply this change to the object associated with this instance in the given transaction.This is a convenience method, equivalent to:
apply(jtx, this.getPermazenObject());
- Parameters:
jtx
- transaction in which to apply this change- Throws:
IllegalArgumentException
- ifjtx
is null
-
apply
public void apply()Apply this change to the transaction associated with the current thread.This is a convenience method, equivalent to:
apply(PermazenTransaction.getCurrent())
- Throws:
IllegalStateException
- if there is noPermazenTransaction
associated with the current thread
-
apply
Apply this change to the specified object.This is a convenience method, equivalent to:
apply(obj.getPermazenTransaction(), jobj);
- Parameters:
jobj
- object to which to apply this change- Throws:
IllegalStateException
- if there is noPermazenTransaction
associated withjobj
IllegalArgumentException
- ifjobj
is null
-
equals
-
hashCode
public int hashCode()
-