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.vocabulary;
17  
18  import jp.liq.container.reflect.ClassFieldFinder;
19  import jp.liq.container.reflect.ObjectFieldFinder;
20  
21  /**
22   * リフレクション API の Wrapper を生成する static メソッド群です。
23   * このクラスで定義されたメソッドは、static インポートして使用すると
24   * 具合が良いように命名されています。
25   * @author nose
26   */
27  public class Fields {
28  
29      /**
30       * FieldFinder を生成します。
31       * 検索の対象となるメソッドは、引数に指定されたjava.lang.Classの、
32       * getMethods メソッドを使用して取得されます。 
33       * @param type フィールドを持つクラス
34       * @return 生成されたFieldFinder
35       */
36      public <T> ClassFieldFinder<T> of(Class<T> type) {
37          ClassFieldFinder<T> rv = new ClassFieldFinder<T>(type);
38          return rv;
39      }
40  
41      public  ObjectFieldFinder of(Object obj) {
42          ObjectFieldFinder rv = new ObjectFieldFinder(obj);
43          return rv;
44      }
45  }