org.easetech.easytest.converter
Class AbstractConverter<Type>
java.lang.Object
org.easetech.easytest.converter.AbstractConverter<Type>
- Type Parameters:
Type - the type of object to convert to.
- All Implemented Interfaces:
- Converter<Type>
public abstract class AbstractConverter<Type>
- extends Object
- implements Converter<Type>
An abstract implementation of the Converter interface that can be used by the user to define their custom
converters. Users are encouraged to extend this class instead of implementing the Converter interface
directly as this class provides the common implementations of convertTo and instanceOfType methods whose
implementations are generic to every Converter.
For an example of a custom converter, you can look at the following :
https://github.com/EaseTech/easytest-core/blob/master/src/test/java/org/easetech/easytest/example/ItemConverter.java
- Author:
- Anuj Kumar
|
Method Summary |
Class<Type> |
convertTo()
Get the Class variable representing the Type object |
Type |
instanceOfType()
Method responsible for returning an instance of the provided Generic Type argument. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.easetech.easytest.converter.Converter |
convert |
AbstractConverter
public AbstractConverter()
convertTo
public Class<Type> convertTo()
- Get the Class variable representing the Type object
- Specified by:
convertTo in interface Converter<Type>
- Returns:
- the Class variable representing the Type object
instanceOfType
public Type instanceOfType()
- Method responsible for returning an instance of the provided Generic Type argument. The default implementation
assumes that the generic type argument is a concrete type with a default no arg constructor. It calls the
Class.newInstance() method to return the instance. If the passed generic type argument is an interface or
an abstract type, then the method calls the Assert.fail() telling the user that the passed Class object
was not a Concrete class.
A user can always extend this behavior to return specific instances in case the passed instance is an interface
or an abstract class. It is recommended to extend the Abstract Converter instead of implementing the Converter
interface directly.
- Specified by:
instanceOfType in interface Converter<Type>
- Returns:
- an instance of the generic type argument passed to the
AbstractConverter
Copyright © 2013. All Rights Reserved.