Home | History | Annotate | Download | only in converters
      1 package junitparams.converters;
      2 
      3 import java.lang.annotation.Annotation;
      4 
      5 /**
      6  * Defines the logic to convert parameter annotated with A to type T. Converter must have a public no-args constructor. Configuration is
      7  * done via {@link Converter#initialize(java.lang.annotation.Annotation)} method<br>
      8  * Inspired by javax.validation.ConstraintValidator
      9  *
     10  * @param <A> type of annotation mentioning this converter
     11  * @param <T> conversion target type
     12  */
     13 public interface Converter<A extends Annotation, T> {
     14 
     15     /**
     16      * Initializes this converter - you can read your annotation config here.
     17      */
     18     void initialize(A annotation);
     19 
     20     /**
     21      * Converts param to desired type.
     22      *
     23      * @throws ConversionFailedException
     24      */
     25     T convert(Object param) throws ConversionFailedException;
     26 }
     27