2 * nothing proxy factory
4 * License : The MIT License
5 * Copyright(c) 2013 MikuToga Partners
8 package jp.sfjp.mikutoga.corelib;
10 import java.lang.reflect.InvocationHandler;
11 import java.lang.reflect.Method;
12 import java.lang.reflect.Proxy;
15 * 何もしないインタフェース実装を生成する。
17 public final class EmptyProxyFactory {
19 /** 何もせず何も返さないInvoker。 */
20 public static InvocationHandler NOTHING_INVOKER = new Nothing();
26 private EmptyProxyFactory(){
28 throw new AssertionError();
33 * 何もしないインタフェース実装のインスタンスを生成する。
34 * <p>インタフェースの各メソッド戻り値はvoidでなければならない。
35 * @param types インタフェース群
36 * @return インタフェースを実装したインスタンス。
38 public static Object buildEmptyProxy(Class<?>... types){
39 ClassLoader loader = types[0].getClassLoader();
42 Proxy.newProxyInstance(loader, types, NOTHING_INVOKER);
51 private static class Nothing implements InvocationHandler{
64 * @param proxy {@inheritDoc}
65 * @param method {@inheritDoc}
66 * @param args {@inheritDoc}
67 * @return {@inheritDoc}
70 public Object invoke(Object proxy, Method method, Object[] args){