01: package com.completex.objective.components.persistency.mapper;
02:
03: /**
04: * Allows to override the default mapping from the value at certain value path
05: *
06: * @author Gennady Krizhevsky
07: */
08: public interface MappingHandler {
09:
10: /**
11: * Establishes conversion rule for a value at the value path
12: *
13: * @param valuePath value path. Value path is defined as <class name>#<value path pattern>. Value path pattern is
14: * a regular expression that will be matched to a field path. The field path is a string of field name separated by
15: * period. Indexed fields at certain index can be referred as <field name>[index].
16: * Example: "com.impl.Bean#fileds\\[(\\d+)\\].childBean" will match "com.impl.Bean#fileds[1].childBean"
17: * @param context request context
18: * @return converted value
19: */
20: Object convert(String valuePath, RequestContext context);
21:
22: public static class Key {
23: private Class beanClass;
24: private Class poClass;
25:
26: public Key(Class beanClass, Class poClass) {
27: this .beanClass = beanClass;
28: this .poClass = poClass;
29: }
30:
31: public boolean equals(Object value) {
32: if (this == value)
33: return true;
34: if (value == null || getClass() != value.getClass())
35: return false;
36:
37: final Key key = (Key) value;
38:
39: if (beanClass != null ? !beanClass.equals(key.beanClass)
40: : key.beanClass != null)
41: return false;
42: if (poClass != null ? !poClass.equals(key.poClass)
43: : key.poClass != null)
44: return false;
45:
46: return true;
47: }
48:
49: public int hashCode() {
50: int result;
51: result = (beanClass != null ? beanClass.hashCode() : 0);
52: result = 29 * result
53: + (poClass != null ? poClass.hashCode() : 0);
54: return result;
55: }
56:
57: }
58:
59: }
|