public abstract class PartialUpdateResourceTask<F,R> extends SessionedTask<R>
Ref
identifying the object to be updated and new data to update the resource with. The latter can be anything, but the most common case will quite likely be the value of a field.
Example:
String session = ...; Ref ref = ... String newname="New_Name"; PartialUpdateResourceTask purt = PartialUpdateResourceTask<String>(ref, newName) { public MyObject applyChange(MyObject myObject) { myObject.setName(this.newValue); return myObject; } }; purt.doExecute(session, false);
Or, in the immutable case, you can just replace the method implementation as follows:
public MyObject applyChange(MyObject myObject) { return new MyObject(myObject.getField1(), this.newValue, myObject.getField2(), ...); }
The template Type F represents the type of the field to be updated within the resource. The type R represents the type of the resource whose field is going to be updated
Modifier and Type | Field and Description |
---|---|
protected F |
newValue
The new data to update the resource with.
|
protected Ref |
ref
The
Ref identifying the resource to be updated. |
Constructor and Description |
---|
PartialUpdateResourceTask(Ref ref, F newValue)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected R |
_execute()
|
protected abstract R |
applyChange(R copyOfData)
Applies the change as described by
newValue to the given object. |
assertExists, assertLocation, assertNONResource, assertNotExists, assertNotLocationData, assertNotNull, assertNotNullElement, assertResource, assertSimple, call, doExecute, doExecute, doExecute, doExecute, expand, getConfigContext, getConfigMBean, getConfigService, getDescription, getSession, isLocation, isReadOnlyTransaction, requiresSystemTransaction
protected final F newValue
protected abstract R applyChange(R copyOfData)
newValue
to the given object. The object that is passed is a copy of the original data. The implementations of this method can either update the copy of the data in-place and return it, or make a copy of the argument and return that.copyOfData
- the object to apply the change toprotected R _execute() throws ValidationException, UpdateException
reference
, applies the change
to it, then updates it with the new version._execute
in class SessionedTask<R>
ValidationException
UpdateException
SessionedTask._execute()