Package org.apache.xbean.recipe
Class Reference
- java.lang.Object
-
- org.apache.xbean.recipe.Reference
-
- Direct Known Subclasses:
ReferenceRecipe.WrapperReference
public class Reference extends java.lang.Object
Reference is a named (lazy) reference from one object to another. This data class is updated when the reference is resolved which can be immedately when the ref is created, or later when an instance with the referenced name is created. When the reference is resolved, an optional Action will be invoked which is commonly used to update a property on the source object of the reference.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Reference.Action
-
Field Summary
Fields Modifier and Type Field Description private Reference.Action
action
private java.lang.Object
instance
private java.lang.String
name
private boolean
resolved
-
Constructor Summary
Constructors Constructor Description Reference(java.lang.String name)
Create a reference to the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get()
Gets the referenced object instance or null if the reference has not been resolved yet;java.lang.String
getName()
Gets the name of the referenced object.boolean
isResolved()
Has this reference been resolved?void
set(java.lang.Object object)
Sets the referenced object instance.void
setAction(Reference.Action action)
Registers an action to invoke when the instance is set.
-
-
-
Field Detail
-
name
private final java.lang.String name
-
resolved
private boolean resolved
-
instance
private java.lang.Object instance
-
action
private Reference.Action action
-
-
Method Detail
-
getName
public java.lang.String getName()
Gets the name of the referenced object.- Returns:
- name the name of the referenced object
-
isResolved
public boolean isResolved()
Has this reference been resolved?- Returns:
- true if the reference has been resolved; false otherwise
-
get
public java.lang.Object get()
Gets the referenced object instance or null if the reference has not been resolved yet;- Returns:
- the referenced object instance or null
-
set
public void set(java.lang.Object object)
Sets the referenced object instance. If an action is registered the onSet method is invoked.- Parameters:
object
- the reference instance
-
setAction
public void setAction(Reference.Action action)
Registers an action to invoke when the instance is set. If the instance, has already been set, the onSet method will immedately be invoked.
-
-