T - the type of the response.public abstract class TypeListener<T> extends java.lang.Object implements ITypeListener<T>
This listener is a helper class providing implementions for the methods
ITypeListener.getType() and ITypeListener.getGenericType().
Instances of this class may be passed to appropriate methods on
AsyncWebResource (or more specifically methods on
AsyncUniformInterface). For example,
AsyncWebResource r = ..
Future<String> f = r.get(new TypeListener<String>(String.class) {
public void onComplete(Future<String> f) throws InterruptedException {
try {
String s = f.get();
} catch (ExecutionException ex) {
// Do error processing
if (t instanceof UniformInterfaceException) {
// Request/response error
} else
// Error making request e.g. timeout
}
}
}
});
| Constructor and Description |
|---|
TypeListener(java.lang.Class<T> type)
Construct a new listener defining the class of the response to receive.
|
TypeListener(GenericType<T> genericType)
Construct a new listener defining the generic type of the response to
receive.
|
| Modifier and Type | Method and Description |
|---|---|
GenericType<T> |
getGenericType()
Get the generic type declaring the Java type of the instance to
receive for
FutureListener.onComplete(java.util.concurrent.Future). |
java.lang.Class<T> |
getType()
Get the class of the instance to receive for
FutureListener.onComplete(java.util.concurrent.Future). |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonCompletepublic TypeListener(java.lang.Class<T> type)
type - the class of the response.public TypeListener(GenericType<T> genericType)
genericType - the generic type of the response.public java.lang.Class<T> getType()
ITypeListenerFutureListener.onComplete(java.util.concurrent.Future).getType in interface ITypeListener<T>public GenericType<T> getGenericType()
ITypeListenerFutureListener.onComplete(java.util.concurrent.Future).getGenericType in interface ITypeListener<T>ITypeListener.getType() must not return null. Otherwise, if not null,
the type information declared by the generic type takes
precedence over the value returned by ITypeListener.getType().Copyright © 2016 Oracle Corporation. All Rights Reserved.