/*
 *  Copyright 2015 Eric Liu
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.liuguangqiang.bowevent;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * Created by Eric on 15/10/8.
 */
public class MethodHandler {

    private Object target;

    private Method method;

    public MethodHandler(Object target, Method method) {
        this.target = target;
        this.method = method;
    }

    public void invoke(Object parameter) {
        try {
            method.invoke(target, parameter);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

}

@@ -796,183 +796,962 @@
     
-private Object target;%0A%0A    private Method method;%0A%0A    public MethodHandler(Object target, Method method) %7B%0A        this.target = target;%0A        this.method = method;%0A    %7D%0A
+/**%0A     * A object that hold the method.%0A     */%0A    private Object target;%0A%0A    /**%0A     * Handler method%0A     */%0A    private Method method;%0A%0A    /**%0A     * If the tag is not null or empty , the method just only be invoked with a correct tag.%0A     */%0A    private String tag;%0A%0A    public MethodHandler(Object target, Method method) %7B%0A        if (target == null) throw new NullPointerException(%22the target cannot be null.%22);%0A%0A        if (method == null) throw new NullPointerException(%22the method cannot be null.%22);%0A%0A        this.target = target;%0A        this.method = method;%0A%0A        Subscribe subscribe = method.getAnnotation(Subscribe.class);%0A        if (subscribe != null) %7B%0A            tag = subscribe.tag();%0A        %7D%0A    %7D%0A%0A    /**%0A     * Return the tag of handler.%0A     *%0A     * @return%0A     */%0A    public String getTag() %7B%0A        return tag;%0A    %7D%0A%0A    /**%0A     * Invoke the method.%0A     *%0A     * @param arg the arguments to the method%0A     */
 %0A   
@@ -1777,25 +1777,19 @@
 (Object 
-p
 ar
-ameter
+g
 ) %7B%0A    
@@ -1836,17 +1836,11 @@
 et, 
-p
 ar
-ameter
+g
 );%0A 

write comments.