All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.objenesis.instantiator.basic.NewInstanceInstantiator Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
package org.objenesis.instantiator.basic;

import org.objenesis.ObjenesisException;
import org.objenesis.instantiator.ObjectInstantiator;

/**
 * The simplest instantiator - simply calls Class.newInstance(). This can deal with default public
 * constructors, but that's about it.
 * 
 * @see ObjectInstantiator
 */
public class NewInstanceInstantiator implements ObjectInstantiator {

   private final Class type;

   public NewInstanceInstantiator(Class type) {
      this.type = type;
   }

   public Object newInstance() {
      try {
         return type.newInstance();
      }      
      catch(Exception e) {
         throw new ObjenesisException(e);
      }
   }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy