Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public <T> void set(final String name, final T value) throws UnhandledTypeException {
- Class<Data<?>> clazz = TypeSystem.getTypeSystem().lookupDataClass(value);
- try {
- Constructor[] consts = clazz.getDeclaredConstructors();
- for (Constructor constructor : consts)
- System.out.println(constructor);
- Constructor constructor = clazz.getConstructor(value.getClass());
- values.put(name, (Data) constructor.newInstance(value));
- } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new UnhandledTypeException("Unhandled Data type: There is no corresponding Data type for the class " + value.getClass().getSimpleName());
- }
- }
- // Console Output:
- // public ninja.genuine.conjure.data.primitive.DataDouble()
- // public ninja.genuine.conjure.data.primitive.DataDouble(double)
- // ninja.genuine.conjure.UnhandledTypeException: Unhandled Data type: There is no corresponding Data type for the class Double
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement