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.Field;
19
20 /**
21 * オブジェクトのフィールドを表現します。
22 * 対象オブジェクトを保持しているため、{@link #get()}、{@link #set(Object)} の引数に
23 * 対象オブジェクトを渡す必要がありません
24 * @author nosen
25 */
26 public class ObjectField extends FieldWrapper {
27
28 private Object target;
29
30 /**
31 * このクラスのインスタンスを構築します。
32 * @param field ラップするフィールド
33 * @param target 対象オブジェクト
34 */
35 public ObjectField(Field field, Object target) {
36 super(field);
37 this.target = target;
38 }
39
40 /**
41 * フィールドの値を取得します。
42 * @return フィールドの値
43 */
44 public Object get() {
45 return super.get(target);
46 }
47
48 /**
49 * フィールドの値を設定します。
50 * @param value 設定する値
51 */
52 public void set(Object value) {
53 super.set(target, value);
54 }
55 }