GenuineSounds icon

Untitled

GenuineSounds | PRO | 01/14/16 11:42:56 AM UTC | 0 ⭐ | 342 👁️ | Never ⏰ | []
Java |

1.01 KB

|

None

|

0 👍

/

0 👎

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

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎