Example usage for com.badlogic.gdx.utils ReflectionPool ReflectionPool

List of usage examples for com.badlogic.gdx.utils ReflectionPool ReflectionPool

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils ReflectionPool ReflectionPool.

Prototype

public ReflectionPool(Class<T> type) 

Source Link

Usage

From source file:com.github.antag99.retinazer.Mapper.java

License:Open Source License

Mapper(Engine engine, Class<T> type, int typeIndex) {
    this.engine = engine;
    this.type = type;
    this.typeIndex = typeIndex;
    Constructor constructor;/*from  w  w  w  . j  a v  a 2s  . c  o  m*/
    try {
        constructor = ClassReflection.getConstructor(type);
        constructor.setAccessible(true);
    } catch (ReflectionException ex) {
        if (ex.getCause() instanceof RuntimeException)
            throw (RuntimeException) ex.getCause();
        constructor = null;
    }
    this.constructor = constructor;
    if (Component.Pooled.class.isAssignableFrom(type)) {
        assert constructor != null : "Pooled component MUST have no-arg constructor! (" + type + ")";
        componentPool = new ReflectionPool<T>(type);
    } else {
        componentPool = null;
    }
}