OSDN Git Service

removed some warning messages
[xerial/xerial-core.git] / src / main / java / org / xerial / util / bean / impl / KeyValuePair.java
1 /*--------------------------------------------------------------------------
2  *  Copyright 2008 Taro L. Saito
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 //--------------------------------------
17 // XerialJ
18 //
19 // KeyValuePair.java
20 // Since: Mar 31, 2008 11:21:41 AM
21 //
22 // $URL$
23 // $Author$
24 //--------------------------------------
25 package org.xerial.util.bean.impl;
26
27 import java.lang.reflect.Method;
28
29 /**
30  * Key and value pair structure for preparing data object for {@link MapPutter}
31  * 
32  * @author leo
33  * 
34  */
35 public class KeyValuePair {
36     public final MapPutter mapPutter;
37
38     private Object key = null;
39     private Object value = null;
40
41     private final Class< ? > keyClass;
42     private final Class< ? > valueClass;
43
44     private int setterCount = 0;
45
46     public KeyValuePair(MapPutter mapPutter) {
47         this.mapPutter = mapPutter;
48         this.keyClass = mapPutter.getKeyType();
49         this.valueClass = mapPutter.getValueType();
50     }
51
52     public KeyValuePair(MapPutter mapPutter, Class< ? > keyType, Class< ? > valueType) {
53         this.mapPutter = mapPutter;
54         this.keyClass = keyType;
55         this.valueClass = valueType;
56     }
57
58     @Override
59     public String toString() {
60         return String.format("%s=>%s", key, value);
61     }
62
63     public boolean hasKeyAndValue() {
64         return key != null && value != null;
65     }
66
67     public Class< ? > keyType() {
68         return keyClass;
69     }
70
71     public Class< ? > valueType() {
72         return valueClass;
73     }
74
75     public Method putter() {
76         return mapPutter.getMethod();
77     }
78
79     public Object getKey() {
80         return key;
81     }
82
83     public void setKey(Object key) {
84         this.key = key;
85     }
86
87     public Object getValue() {
88         return value;
89     }
90
91     public void setValue(Object value) {
92         this.value = value;
93     }
94
95 }