T - the kind of resource this ResourceRequest providespublic abstract class ResourceRequest<T> extends Object
ResourceRequest describes an algorithm for finding or creating a resource by calling
a set of resource providers or factories in a specific order.| Constructor and Description |
|---|
ResourceRequest() |
| Modifier and Type | Method and Description |
|---|---|
void |
answer(T resource)
Informs this request that
resource should be user. |
protected abstract void |
answer(T previousResource,
T newResource)
Called when the requested resource changed.
|
protected abstract void |
executeRequestList()
Asks all sources for a new resource, needs to stop as soon
as one source called
answer(Object) (this can be queried
with isAnswered()). |
T |
getAnswer()
Gets the last answer made to this request.
|
boolean |
isAnswered()
Tells whether
answer(Object) was called since the last request(). |
protected void |
request()
Asks for a new resource and may trigger
answer(Object, Object). |
void |
requestNull()
Asks this request to simulate a call to
request() which is
answered with null |
protected abstract void |
validate(T resource)
Called by
answer(Object), this method ensure that resource is a valid answer. |
protected abstract void answer(T previousResource, T newResource)
previousResource - the old resource object, may be nullnewResource - the new resource object, may be nullprotected void request()
answer(Object, Object). This method
is made protected, subclasses can expose it, or write another method requiring additional
parameters, that calls this method.public boolean isAnswered()
answer(Object) was called since the last request().true if there is an answerprotected abstract void executeRequestList()
answer(Object) (this can be queried
with isAnswered()).public void requestNull()
request() which is
answered with nullpublic void answer(T resource)
resource should be user. This method
can be called more than once to use different resources. Subclasses may put strict demands on
what objects are valid resource objects. This method is not intended to be called in a generic way, callers
must be aware of the restrictions a subclass requires.
An answer must fulfill some rules:resource - the new resource or nullIllegalArgumentException - if the resource does not met the specifications a subclass requiresIllegalStateException - if request() is not currently executingprotected abstract void validate(T resource)
answer(Object), this method ensure that resource is a valid answer. The method
throws an IllegalArgumentException if not.resource - the resource to checkIllegalArgumentException - if resource is not a valid resourcepublic T getAnswer()
nullCopyright © 2017 Docking Frames. All rights reserved.