|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Dynamic
Dynamics are wrapper objects that are capable of receiving any
message, and determine on runtime which method of the wrapped objecy will be
actually evaluated.
If there is no method matching the message, errors will not occur in compile
time, but in runtime - a MessageNotUnderstoodException will be thrown
| Method Summary | ||
|---|---|---|
Dynamic |
$(String selector,
Object... args)
Synonym for chainingSend(String, Object...) |
|
|
as(Class<T> clazz)
"casts" this dynamic to the desired type, by returning the wrapped value, if it can be casted to the given class, or by returning a proxy that forwards messages to send(String, Object...), otherwise. |
|
|
chainingAs(Class<T> clazz)
"casts" this dynamic to the desired type, by returning the wrapped value, if it can be casted to the given class, or by returning a proxy that forwards messages to chainingSend(String, Object...), casting with
chainingAs(Class) the result to the desired method return type,
otherwise. |
|
Dynamic |
chainingSend(String selector,
Object... args)
Sends a message to this Dynamic, as defined by
send(String, Object...), and returns the message result wrapped as
a dynamic, or Dynamics.null_(), if the result was
null. |
|
|
delayedSend(String selector,
Object... args)
Asynchronously sends a message to this dynamic object by returning a thunk that, when evaluated, performs the actual message passing |
|
|
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()
The wrapped value |
|
| Method Detail |
|---|
<T> T send(@NonNull
String selector,
@NonNull
Object... args)
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.
T - selector - the message nameargs - the message arguments
MessageNotUnderstoodException - if this dynamic object does not understand the given message
MethodEvaluationException - if a matching method exists, but its evaluation threw a an
exception. The original exception is its cause
@NonNull
Dynamic chainingSend(@NonNull
String selector,
@NonNull
Object... args)
Dynamic, as defined by
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
selector - args -
null. The message result, wrapped as a Dynamic,
otherwise.
MethodEvaluationException - if a matching method exists, but its evaluation threw a an
exception. The original exception is its causeDynamics.null_()
@NonNull
Dynamic $(@NonNull
String selector,
@NonNull
Object... args)
chainingSend(String, Object...)
selector - args -
chainingSend(String, Object...)
@NonNull
<T> net.sf.staccatocommons.defs.Thunk<T> delayedSend(@NonNull
String selector,
@NonNull
Object... args)
T - selector - the message selectorargs - the message arguments
@NonNull
<T> T as(@NonNull
Class<T> clazz)
send(String, Object...), otherwise.
Methods must throw ClassCastException if the
actual returned value of the dynamic can not be cast the the returned value
of the method, and NullPointerException if null is returned when a
primitive return type is expected
T - clazz -
Dynamic
@NonNull
<T> T chainingAs(@NonNull
Class<T> clazz)
chainingSend(String, Object...), casting with
chainingAs(Class) the result to the desired method return type,
otherwise.
Methods must throw NullPointerException if null is
returned when a primitive return type is expected
T - clazz -
DynamicObject value()
value in interface net.sf.staccatocommons.defs.Thunk<Object>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||