Kalle Stenflo
13 years ago
6 changed files with 96 additions and 42 deletions
@ -0,0 +1,24 @@
|
||||
package com.jayway.jsonpath.spi; |
||||
|
||||
import org.codehaus.jackson.map.type.CollectionType; |
||||
import org.codehaus.jackson.map.type.TypeFactory; |
||||
import org.codehaus.jackson.map.type.TypeModifier; |
||||
import org.codehaus.jackson.map.type.TypeParser; |
||||
import org.codehaus.jackson.type.JavaType; |
||||
|
||||
import java.util.Collection; |
||||
|
||||
/** |
||||
* Created by IntelliJ IDEA. |
||||
* User: kallestenflo |
||||
* Date: 3/5/12 |
||||
* Time: 11:03 AM |
||||
*/ |
||||
public interface MappingProvider { |
||||
|
||||
|
||||
public <T> T convertValue(Object fromValue, Class<T> toValueType) throws IllegalArgumentException; |
||||
|
||||
public <T extends Collection<E>, E> T convertValue(Object fromValue, Class<T> collectionType, Class<E> elementType) throws IllegalArgumentException; |
||||
|
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.jayway.jsonpath.spi; |
||||
|
||||
import com.jayway.jsonpath.spi.impl.JacksonProvider; |
||||
|
||||
/** |
||||
* Created by IntelliJ IDEA. |
||||
* User: kallestenflo |
||||
* Date: 3/5/12 |
||||
* Time: 11:03 AM |
||||
*/ |
||||
public class MappingProviderFactory { |
||||
|
||||
private static MappingProvider mappingProvider; |
||||
|
||||
static { |
||||
try { |
||||
Class.forName("org.codehaus.jackson.map.ObjectMapper"); |
||||
|
||||
mappingProvider = new JacksonProvider(); |
||||
} catch (ClassNotFoundException e) { |
||||
throw new RuntimeException("org.codehaus.jackson.map.ObjectMapper not found on classpath. This is an optional dependency needed for POJO conversions.", e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
public static MappingProvider getInstance() { |
||||
return mappingProvider; |
||||
} |
||||
} |
Loading…
Reference in new issue