1 /*--------------------------------------------------------------------------
2 * Copyright 2008 Taro L. Saito
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 //--------------------------------------
20 // Since: Mar 31, 2008 11:21:41 AM
24 //--------------------------------------
25 package org.xerial.util.bean.impl;
27 import java.lang.reflect.Method;
30 * Key and value pair structure for preparing data object for {@link MapPutter}
35 public class KeyValuePair {
36 public final MapPutter mapPutter;
38 private Object key = null;
39 private Object value = null;
41 private final Class< ? > keyClass;
42 private final Class< ? > valueClass;
44 private int setterCount = 0;
46 public KeyValuePair(MapPutter mapPutter) {
47 this.mapPutter = mapPutter;
48 this.keyClass = mapPutter.getKeyType();
49 this.valueClass = mapPutter.getValueType();
52 public KeyValuePair(MapPutter mapPutter, Class< ? > keyType, Class< ? > valueType) {
53 this.mapPutter = mapPutter;
54 this.keyClass = keyType;
55 this.valueClass = valueType;
59 public String toString() {
60 return String.format("%s=>%s", key, value);
63 public boolean hasKeyAndValue() {
64 return key != null && value != null;
67 public Class< ? > keyType() {
71 public Class< ? > valueType() {
75 public Method putter() {
76 return mapPutter.getMethod();
79 public Object getKey() {
83 public void setKey(Object key) {
87 public Object getValue() {
91 public void setValue(Object value) {