Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/schema_salad/java/main_utils/RecordLoader.java @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
author | shellac |
---|---|
date | Sat, 02 May 2020 07:14:21 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:26e78fe6e8c4 |
---|---|
1 package ${package}.utils; | |
2 | |
3 import java.lang.reflect.Constructor; | |
4 import java.lang.reflect.InvocationTargetException; | |
5 | |
6 public class RecordLoader<T extends Savable> implements Loader<T> { | |
7 private final Class<? extends T> savableClass; | |
8 | |
9 public RecordLoader(final Class<? extends T> savableClass) { | |
10 this.savableClass = savableClass; | |
11 } | |
12 | |
13 public T load( | |
14 final Object doc, | |
15 final String baseUri, | |
16 final LoadingOptions loadingOptions, | |
17 final String docRoot) { | |
18 Loader.validateOfJavaType(java.util.Map.class, doc); | |
19 try { | |
20 final Constructor<? extends T> constructor = | |
21 this.savableClass.getConstructor( | |
22 new Class[] {Object.class, String.class, LoadingOptions.class, String.class}); | |
23 final T ret = constructor.newInstance(doc, baseUri, loadingOptions, docRoot); | |
24 return ret; | |
25 } catch (InvocationTargetException e) { | |
26 final Throwable cause = e.getCause(); | |
27 if (cause instanceof RuntimeException) { | |
28 throw (RuntimeException) cause; | |
29 } | |
30 throw new RuntimeException(e.getCause()); | |
31 } catch (ReflectiveOperationException e) { | |
32 throw new RuntimeException(e); | |
33 } | |
34 } | |
35 | |
36 } |