public interface RequestContext
FakeRequestContext
Modifier and Type | Method and Description |
---|---|
<T extends RequestContext> |
append(T other)
Joins another RequestContext to this RequestContext.
|
<T extends BaseProxy> |
create(java.lang.Class<T> clazz)
Returns a new mutable proxy that this request can carry to the server,
perhaps to be persisted.
|
<T extends BaseProxy> |
edit(T object)
Returns a mutable version of the proxy, whose mutations will accumulate in
this context.
|
<P extends EntityProxy> |
find(EntityProxyId<P> proxyId)
Return a request to find a fresh instance of the referenced proxy.
|
void |
fire()
Send the accumulated changes and method invocations associated with the
RequestContext.
|
void |
fire(Receiver<java.lang.Void> receiver)
For receiving errors or validation failures only.
|
RequestFactory |
getRequestFactory()
Returns the
RequestFactory that created the RequestContext. |
boolean |
isChanged()
Returns true if any changes have been made to proxies mutable under this
context.
|
<T extends RequestContext> T append(T other)
SomeContext ctx = myFactory.someContext(); // Perform operations on ctx OtherContext other = ctx.append(myFactory.otherContext()); // Perform operations on both other and ctx ctx.fire() // or other.fire() are equivalent
other
- a freshly-constructed RequestContext whose state should be
bound to this RequestContextother
java.lang.IllegalStateException
- if any methods have been called on
other
or if other
was constructed by a different
RequestFactory instance<T extends BaseProxy> T create(java.lang.Class<T> clazz)
clazz
- a Class object of type TBaseProxy
instance of type T<T extends BaseProxy> T edit(T object)
object
- an instance of type TEntityProxy
or ValueProxy
instance of type T<P extends EntityProxy> Request<P> find(EntityProxyId<P> proxyId)
proxyId
- an EntityProxyId
instance of type PRequest
objectvoid fire()
If Request.to(Receiver)
has not been called, this method will
install a default receiver that will throw a RuntimeException if there is a
server failure.
void fire(Receiver<java.lang.Void> receiver)
receiver
- a Receiver
instancejava.lang.IllegalArgumentException
- if receiver
is
null
RequestFactory getRequestFactory()
RequestFactory
that created the RequestContext.boolean isChanged()
String name = bar.getName(); bar.setName("something else"); assertTrue(context.isChanged()); bar.setName(name); assertFalse(context.isChanged());
true
if any changes have been made