Package com.artemis.utils.reflect

Examples of com.artemis.utils.reflect.Constructor.newInstance()


  @SuppressWarnings("unchecked")
  <T extends Component> T newInstance(Class<T> componentClass, boolean constructorHasWorldParameter) {
    try {
      if (constructorHasWorldParameter) {
        Constructor constructor = ClassReflection.getConstructor(componentClass, World.class);
        return (T) constructor.newInstance(world);
      } else {
        return ClassReflection.newInstance(componentClass);
      }
    } catch (ReflectionException e) {
      throw new InvalidComponentException(componentClass, "Unable to instantiate component.", e);
View Full Code Here


   
    String impl = factory.getName() + "Impl";
    try {
      Class<?> implClass = ClassReflection.forName(impl);
      Constructor constructor = ClassReflection.getConstructor(implClass, World.class);
      return (T) constructor.newInstance(this);
    } catch (ReflectionException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.