FileDocCategorySizeDatePackage
Decorator.javaAPI DocAndroid 5.1 API3208Thu Mar 12 22:22:10 GMT 2015android.hardware.camera2.utils

Decorator

public class Decorator extends Object implements InvocationHandler
This is an implementation of the 'decorator' design pattern using Java's proxy mechanism.
see
android.hardware.camera2.utils.Decorator#newInstance
hide

Fields Summary
private final T
mObject
private final DecoratorListener
mListener
Constructors Summary
private Decorator(T obj, DecoratorListener listener)

        this.mObject = obj;
        this.mListener = listener;
    
Methods Summary
public java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method m, java.lang.Object[] args)

        Object result = null;
        try {
            mListener.onBeforeInvocation(m, args);
            result = m.invoke(mObject, args);
            mListener.onAfterInvocation(m, args, result);
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            if (!mListener.onCatchException(m, args, t)) {
                throw t;
            }
        } finally {
            mListener.onFinally(m, args);
        }
        return result;
    
public static TnewInstance(T obj, android.hardware.camera2.utils.Decorator$DecoratorListener listener)
Create a decorator wrapping the specified object's method calls.

param
obj the object whose method calls you want to intercept
param
listener the decorator handler for intercepted method calls
param
the type of the element you want to wrap. This must be an interface.
return
a wrapped interface-compatible T

        return (T)java.lang.reflect.Proxy.newProxyInstance(
                obj.getClass().getClassLoader(),
                obj.getClass().getInterfaces(),
                new Decorator<T>(obj, listener));