Home | History | Annotate | Download | only in converters
      1 package junitparams.converters;
      2 
      3 
      4 public class NullableConverter implements Converter<Nullable, String>{
      5 
      6     private String nullIdentifier;
      7 
      8     public void initialize(Nullable annotation) {
      9         nullIdentifier = annotation.nullIdentifier() == null ? "null" : annotation.nullIdentifier();
     10     }
     11 
     12     public String convert(Object param) throws ConversionFailedException {
     13         if(param instanceof String && ((String)param).trim().equalsIgnoreCase(nullIdentifier)){
     14                 return null;
     15         }
     16         return (String)param;
     17     }
     18 
     19 }