fromInputStream using generics
Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
parent
f11c773f8a
commit
47ca69c435
|
@ -61,7 +61,17 @@ public final class Json {
|
|||
throw new IllegalStateException("Failed to encode as JSON: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static <T> T fromInputStream(final InputStream inputStream,
|
||||
Class<T> clazz) {
|
||||
try {
|
||||
return MAPPER.readValue(inputStream, clazz);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Failed to encode as JSON: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a given JSON string to a CloudEvent .
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue