/
ParamAwareConverter.java
27 lines (23 loc) · 1.13 KB
/
ParamAwareConverter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package org.easetech.easytest.converter;
import java.util.Map;
/**
* Decorator of {@link Converter} to provide the name of the parameter
* to the implementing class. Users who are extending from {@link AbstractConverter}
* will have no effect on their existing converters. On top of that they will now
* have access to the parameter name using the {@link AbstractConverter#getParamName()} method.
* Users who are directly implementing {@link Converter} interface will have to switch to either
* {@link ParamAwareConverter} or {@link AbstractConverter} to get the parameter name.
*
* @param <Type> the type of object to convert to from a map.
*
* @author Anuj Kumar
*/
public interface ParamAwareConverter<Type> extends Converter<Type> {
/**
* Convert the Map into a user defined object and also expect the param name
* @param convertFrom the {@link Map} to convert from
* @param paramName the name of the parameter for which this converter is called
* @return the object to convert to identified by {@link #convertTo()} class.
*/
Type convert(Map<String , Object> convertFrom , String paramName);
}