net.sf.staccatocommons.dynamic.internal
Class ReflectiveDynamic
java.lang.Object
net.sf.staccatocommons.dynamic.AbstractDynamic
net.sf.staccatocommons.dynamic.internal.ReflectiveDynamic
- All Implemented Interfaces:
- net.sf.staccatocommons.defs.Thunk<Object>, Dynamic
public final class ReflectiveDynamic
- extends AbstractDynamic
- Author:
- flbulgarelli
|
Method Summary |
Dynamic |
chainingSend(String selector,
Object... args)
Sends a message to this Dynamic, as defined by
Dynamic.send(String, Object...), and returns the message result wrapped as
a dynamic, or Dynamics.null_(), if the result was
null. |
|
send(String selector,
Object... args)
Sends a message to this Dynamic, and returns the message result
If there is no method matching for the given selector and argument count
and types, the message is said to not being understood and a
MessageNotUnderstoodException is thrown
If there exists more than one method matching the given selector and
arguments count and types, Dynamic makes no assumptions about which one
will be evaluated. |
Object |
value()
Answers the object wrapped by this dynamic |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReflectiveDynamic
public ReflectiveDynamic(@NonNull
Object target)
- Creates a new
ReflectiveDynamic
- Parameters:
target - the object to wrap
send
public <T> T send(@NonNull
String selector,
@NonNull
Object... args)
- Description copied from interface:
Dynamic
- Sends a message to this
Dynamic, and returns the message result
If there is no method matching for the given selector and argument count
and types, the message is said to not being understood and a
MessageNotUnderstoodException is thrown
If there exists more than one method matching the given selector and
arguments count and types, Dynamic makes no assumptions about which one
will be evaluated.
- Parameters:
selector - the message nameargs - the message arguments
- Returns:
- the message result
chainingSend
public Dynamic chainingSend(String selector,
Object... args)
- Description copied from interface:
Dynamic
- Sends a message to this
Dynamic, as defined by
Dynamic.send(String, Object...), and returns the message result wrapped as
a dynamic, or Dynamics.null_(), if the result was
null.
If the message is not understood, instead of throwing an exception, this
method returns the null dynamic.
This method makes chaining dynamic methods easier. Example:
Dynamics.from(anObject).$("getFoo").$("getBar").$("getBaz").value()
This will return the messages chain result, or null, if any message of the
chain returned null or was not understood
- Returns:
- the null dynamic if the message was not understood or if answered
null. The message result, wrapped as a Dynamic,
otherwise. - See Also:
Dynamics.null_()
value
public Object value()
- Answers the object wrapped by this dynamic
Copyright © 2010-2011 Staccato-Commons. All Rights Reserved.