package com.completex.objective.components.persistency.mapper;
/**
* Allows to override the default mapping from the value at certain value path
*
* @author Gennady Krizhevsky
*/
public interface MappingHandler {
/**
* Establishes conversion rule for a value at the value path
*
* @param valuePath value path. Value path is defined as <class name>#<value path pattern>. Value path pattern is
* a regular expression that will be matched to a field path. The field path is a string of field name separated by
* period. Indexed fields at certain index can be referred as <field name>[index].
* Example: "com.impl.Bean#fileds\\[(\\d+)\\].childBean" will match "com.impl.Bean#fileds[1].childBean"
* @param context request context
* @return converted value
*/
Object convert(String valuePath, RequestContext context);
public static class Key {
private Class beanClass;
private Class poClass;
public Key(Class beanClass, Class poClass) {
this.beanClass = beanClass;
this.poClass = poClass;
}
public boolean equals(Object value) {
if (this == value) return true;
if (value == null || getClass() != value.getClass()) return false;
final Key key = (Key) value;
if (beanClass != null ? !beanClass.equals(key.beanClass) : key.beanClass != null) return false;
if (poClass != null ? !poClass.equals(key.poClass) : key.poClass != null) return false;
return true;
}
public int hashCode() {
int result;
result = (beanClass != null ? beanClass.hashCode() : 0);
result = 29 * result + (poClass != null ? poClass.hashCode() : 0);
return result;
}
}
}
|