// obtain RNG Class from first generic parameter
final Class<RNG> rngClass = (Class<RNG>) TypeToken.getClazz(GenericPseudoRandom.class, 0);
final Constructor<RNG> c = rngClass.getConstructor(long.class);
rng = c.newInstance(seed);
} catch (final Exception e) {
throw new LibraryException(e); // QA:[RG]::verified
}
// instantiate a RandomSequenceGenerator given a RNG type
final RandomSequenceGenerator<RNG> rsg;
try {
// obtain Class from previously created RNG variable
final Class<RandomSequenceGenerator<RNG>> rsgClass = (Class<RandomSequenceGenerator<RNG>>) TypeToken.getClazz(rng.getClass());
final Constructor<RandomSequenceGenerator<RNG>> c = rsgClass.getConstructor(int.class, rng.getClass());
rsg = c.newInstance(dimension, rng);
} catch (final Exception e) {
throw new LibraryException(e); // QA:[RG]::verified
}
// instantiate a InverseCumulative given its generic type (second generic parameter)
final IC ic;
try {
// obtain IC Class from second generic parameter
final Class<IC> icClass = (Class<IC>) TypeToken.getClazz(GenericPseudoRandom.class, 1);
final Constructor<IC> c;
if (icInstance!=null) {
c = icClass.getConstructor(rsg.getClass(), icClass.getClass());
ic = c.newInstance(rsg, icInstance);
} else {
c = icClass.getConstructor(rsg.getClass());
ic = c.newInstance(rsg);
}
} catch (final Exception e) {
throw new LibraryException(e); // QA:[RG]::verified
}
return (InverseCumulativeRsg<RandomSequenceGenerator<RNG>, IC>) ic;
}