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 final InvocationHandler NOTHING_INVOKER = new Nothing();
26 private EmptyProxyFactory(){
28 throw new AssertionError();
33 * 何もしないインタフェース実装のインスタンスを生成する。
35 * <p>インタフェースの各メソッド戻り値はvoidでなければならない。
37 * @param types インタフェース群
38 * @return インタフェースを実装したインスタンス。
40 public static Object buildEmptyProxy(Class<?>... types){
41 ClassLoader loader = types[0].getClassLoader();
44 Proxy.newProxyInstance(loader, types, NOTHING_INVOKER);
53 private static class Nothing implements InvocationHandler{
66 * @param proxy {@inheritDoc}
67 * @param method {@inheritDoc}
68 * @param args {@inheritDoc}
69 * @return {@inheritDoc}
72 public Object invoke(Object proxy, Method method, Object[] args){