public class ClosureModel
extends Object
implements NestedValueModel, ValueModel
Represents a value model using a closure to extract the value from some source model and an optional write closure for updating the value.
| Constructor and description |
|---|
ClosureModel(ValueModel sourceModel, Closure readClosure)Creates a read-only closure-backed model. |
ClosureModel(ValueModel sourceModel, Closure readClosure, Closure writeClosure)Creates a closure-backed model with explicit read and write closures. |
ClosureModel(ValueModel sourceModel, Closure readClosure, Closure writeClosure, Class type)Creates a closure-backed model with an explicit declared type. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public ValueModel |
getSourceModel()Returns the model that supplies the source object consumed by the closures. |
|
public Class |
getType()Returns the declared value type for this derived model. |
|
public Object |
getValue()Evaluates the current source object through the read closure. |
|
public boolean |
isEditable()Indicates whether this model has a write closure. |
|
public void |
setValue(Object value)Applies the write closure to the current source object when the model is editable. |
Creates a read-only closure-backed model.
sourceModel - the model that supplies the source objectreadClosure - the closure used to read the derived valueCreates a closure-backed model with explicit read and write closures.
sourceModel - the model that supplies the source objectreadClosure - the closure used to read the derived valuewriteClosure - the closure used to write back a new value, or null for read-only accessCreates a closure-backed model with an explicit declared type.
sourceModel - the model that supplies the source objectreadClosure - the closure used to read the derived valuewriteClosure - the closure used to write back a new value, or null for read-only accesstype - the declared type of the derived valueReturns the model that supplies the source object consumed by the closures.
Returns the declared value type for this derived model.
Evaluates the current source object through the read closure.
null if the source model currently holds nullIndicates whether this model has a write closure.
true when a write closure is availableApplies the write closure to the current source object when the model is editable.
value - the value to writeCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.