KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > PropertyReadingBinder


1 /*****************************************************************************
2  * Copyright (C) Zephyr Business Solution. All rights reserved. *
3  * ------------------------------------------------------------------------- *
4  * The software in this package is published under the terms of the BSD *
5  * style license a copy of which has been included with this distribution in *
6  * the LICENSE.txt file. *
7  *****************************************************************************/

8
9 /*
10  * Created on Apr 22, 2005
11  *
12  * Author Ben Yu
13  * ZBS
14  */

15 package jfun.yan;
16
17 import jfun.util.beans.Bean;
18 import jfun.util.beans.BeanType;
19 import jfun.yan.function.Function;
20
21 /**
22  * Zephyr Business Solution
23  *
24  * @author Ben Yu
25  *
26  */

27 final class PropertyReadingBinder
28 extends BeanPropertyComponentBinder implements ComponentBinder {
29   private final BeanType beanType;
30   private final String JavaDoc prop;
31   
32   PropertyReadingBinder(final BeanType beanType, final String JavaDoc prop) {
33     this.beanType = beanType;
34     this.prop = prop;
35   }
36   
37   Function toFunction(Object JavaDoc v){
38     return Functions.getter(Bean.instance(beanType,v), prop);
39   }
40   public boolean equals(Object JavaDoc obj) {
41     if(obj instanceof PropertyReadingBinder){
42       final PropertyReadingBinder other = (PropertyReadingBinder)obj;
43       return prop.equals(other.prop) && beanType.equals(other.beanType);
44     }
45     else return false;
46   }
47   public int hashCode() {
48     return beanType.hashCode()*31+prop.hashCode();
49   }
50 }
51
Popular Tags