KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > IndexedPropertyReadingBinder


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