KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jfun > yan > DynamicBinder


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 11, 2005
11  *
12  * Author Ben Yu
13  * ZBS
14  */

15 package jfun.yan;
16
17 /**
18  * Adapts a Binder object to a ComponentBinder object
19  * by making the verification method a no-op.
20  * <p>
21  * Zephyr Business Solution
22  *
23  * @author Ben Yu
24  *
25  */

26 final class DynamicBinder<From,To> implements ComponentBinder<From,To> {
27   private final Binder<From,To> binder;
28   
29   DynamicBinder(final Binder<From,To> binder) {
30     this.binder = binder;
31   }
32   public Creator<To> bind(From v) throws Throwable JavaDoc {
33     return binder.bind(v);
34   }
35   public boolean equals(Object JavaDoc obj) {
36     if(obj instanceof DynamicBinder){
37       final DynamicBinder other = (DynamicBinder)obj;
38       return binder.equals(other.binder);
39     }
40     else return false;
41   }
42   public int hashCode() {
43     return binder.hashCode();
44   }
45   public String JavaDoc toString() {
46     return binder.toString();
47   }
48   public Verifiable verify(Class JavaDoc<From> type) {
49     return Monad.pass().verify(Object JavaDoc.class);
50   }
51   public Class JavaDoc bindType(Class JavaDoc t){
52     return null;
53   }
54 }
55
Popular Tags