OSDN Git Service

空読みスキップ対応
[mikutoga/TogaGem.git] / src / main / java / jp / sourceforge / mikutoga / pmd / parser / NullHandler.java
1 /*
2  * PMD nothing handler
3  *
4  * License : The MIT License
5  * Copyright(c) 2013 MikuToga Partners
6  */
7
8 package jp.sourceforge.mikutoga.pmd.parser;
9
10 import java.lang.reflect.InvocationHandler;
11 import java.lang.reflect.Method;
12 import java.lang.reflect.Proxy;
13
14 /**
15  * 何もしない統合ハンドラを提供する。
16  */
17 public final class NullHandler{
18
19     /** 何もしない統合ハンドラ。 */
20     public static final PmdUnifiedHandler HANDLER;
21
22     static{
23         Class types[] = { PmdUnifiedHandler.class };
24         ClassLoader loader = types[0].getClassLoader();
25         InvocationHandler nothing = new Nothing();
26
27         Object proxy = Proxy.newProxyInstance(loader, types, nothing);
28         assert proxy instanceof PmdUnifiedHandler;
29
30         HANDLER = (PmdUnifiedHandler) proxy;
31     }
32
33
34     /**
35      * ダミーコンストラクタ。
36      */
37     private NullHandler(){
38         assert false;
39         throw new AssertionError();
40     }
41
42
43     /**
44      * 何もしないInvoker実装。
45      */
46     private static class Nothing implements InvocationHandler{
47
48         /**
49          * コンストラクタ。
50          */
51         Nothing(){
52             super();
53             return;
54         }
55
56         /**
57          * {@inheritDoc}
58          * NOTHING...
59          * @param proxy {@inheritDoc}
60          * @param method {@inheritDoc}
61          * @param args {@inheritDoc}
62          * @return {@inheritDoc}
63          */
64         @Override
65         public Object invoke(Object proxy, Method method, Object[] args){
66             return null;
67         }
68
69     }
70
71 }