View Javadoc

1   /*
2    * Copyright 2007-2008 Naoki NOSE.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package jp.liq.container.reflect;
17  
18  import java.lang.reflect.Method;
19  
20  /**
21   * オブジェクトのメソッドを表現します。
22   * 対象オブジェクトを保持しているため、{@link #invoke(Object...)} 
23   * の引数に対象オブジェクトを渡す必要がありません。
24   * @author nosen
25   *
26   */
27  public class ObjectMethod extends MethodWrapper {
28      private final Object target;
29      
30      /**
31       * @param method
32       */
33      public ObjectMethod(Method method, Object target) {
34          super(method);
35          this.target = target;
36      }
37  
38      public Object invoke(Object... args) {
39          return super.invoke(target, args);
40      }
41  
42      public <T> ObjectFactory<T> createObjectFactory(Class<T> type) {
43          return super.createObjectFactory(target, type);
44      }
45  }