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

org.snapscript.core.type.index.PrimitiveFunctionAccessor Maven / Gradle / Ivy

package org.snapscript.core.type.index;

import java.lang.reflect.Constructor;

import org.snapscript.core.error.InternalStateException;

public class PrimitiveFunctionAccessor {

   public PrimitiveFunctionAccessor() {
      super();
   }

   public  T create(Class type) {
      try {
         Constructor constructor = type.getDeclaredConstructor();
         
         if(!constructor.isAccessible()) {
            constructor.setAccessible(true);
         }
         return (T)constructor.newInstance();
      } catch(Exception e) {
         throw new InternalStateException("Error creating " + type, e);
      }
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy