Use a constructor of the a class to create an instance
@param aClass the class the create
@param <T> the type class
@return the initiate object
557243
@SuppressWarnings("unchecked")
	public static <T> T newInstance(Class<?> aClass) 
	{
		if(aClass == null)
			return null;
		
				try
				{
					if(String.class.equals(aClass))
					{
						return (T)"";
					}
					else if(Integer.class.equals(aClass))
					{
						return (T)Integer.valueOf(0);
					}
					else if(Date.class.equals(aClass))
					{
						return (T)Calendar.getInstance().getTime();
					}				
					else if(Long.class.equals(aClass) ||
							long.class.equals(aClass))
					{
						return (T)Long.valueOf(0);
					}		
					else if(Character.class.equals(aClass) ||
							char.class.equals(aClass) )
					{
						return (T) Character.valueOf('\0');
					}
					else if(Float.class.equals(aClass) ||
							float.class.equals(aClass))
					{
						return (T)Float.valueOf(0);
					}
					else if(Double.class.equals(aClass) || 
						   double.class.equals(aClass))
					{
						return (T)Double.valueOf(0);
					}				
					
					Constructor<T> constructor = (Constructor<T>)aClass.getDeclaredConstructor();
					
					
					return (T)constructor.newInstance();
					
				}
				catch(IllegalAccessException e)
				{
					throw new SetupException("Trying to create "+aClass.getName()+" "+e.getMessage());
				}
				catch(NoSuchMethodException | InvocationTargetException | InstantiationException e)
				{
						//Get constructor
						Constructor<?>[] constructors = aClass.getConstructors();
							
						int len = constructors.length;
						for(int i=0; i < len; i++)
						{
							Class<?>[] parameterTypes = constructors[i].getParameterTypes();
						    
							if(parameterTypes == null || parameterTypes.length == 0)
								throw new SetupException("Trying to create "+aClass.getName()+" "+e.getMessage()); //has a default constructor but not able to create it
							
							//Construct arguments
							Object[] initargs = new Object[parameterTypes.length];
							
							for(int argsIndex=0; argsIndex <  initargs.length;argsIndex++)
							{
								initargs[argsIndex] = newInstance(parameterTypes[argsIndex]);
							}
							
							try
							{
								return (T)constructors[i].newInstance(initargs);
							}
							catch(Exception exception)
							{}
						}//end for constructors
						
						//not able to success use another constructor
						throw new SetupException("Trying to create class with name:"+aClass.getName()+" ERROR:"+e.getMessage());	
					}//end catch
			}
854534
public Object create(String name, Object... args)
    throws ClassNotFoundException,
           NoSuchMethodException,
           IllegalAccessException,
           InstantiationException,
           InvocationTargetException
    {
//StringBuilder sb = new StringBuilder("DefaultObjectFactory.create(").append(name).append(',');
//for (Object arg: args) {
//sb.append(arg.getClass().getName()).append(' ');
//}
//sb.append(')');
//System.err.println(sb);
        try {
            Class<?> type = Class.forName(name);
/*
            Constructor<?>[] constructors = type.getConstructors();
            for (Constructor<?> constructor: constructors) {
                Class<?>[] ptypes = constructor.getParameterTypes();
                if (ptypes.length == args.length) {
                    try {
                        return constructor.newInstance(args);
                    } catch (IllegalArgumentException x) {
                        // ignore and try the next one
                    } catch (IllegalAccessException x) {
                        throw x;
                    } catch (InstantiationException x) {
                        throw x;
                    } catch (InvocationTargetException x) {
                        throw x;
                    }
                }
            }
            throw new NoSuchMethodException("Can't locate a desired constructor in " + name);
*/
//System.err.println("DefaultObjectFactory.create: successful");
            return Beans.create(type, args);
        } catch (ClassNotFoundException x) {
            throw x;
        }
    }
411121
public static <T> T newInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new XOException("Cannot create instance of type '" + type.getName() + "'", e);
        } catch (IllegalAccessException e) {
            throw new XOException("Access denied to type '" + type.getName() + "'", e);
        }
    }
1368431
public static <T> T newInstance(Class<?> aClass, Object... initargs) 
	throws SetupException
	{
		Class<?>[] parameterTypes = null;
		
		if(initargs != null && initargs.length > 0)
		{
			parameterTypes = new Class<?>[initargs.length];
			
			for (int i = 0; i < initargs.length; i++)
			{
				if(initargs[i] == null)
					continue; //skip
				
				parameterTypes[i] = initargs[i].getClass();
			}
		}
		
		return newInstance(aClass,parameterTypes,initargs);
	}
1315444
@Nonnull
  public static <T> UBL21ValidatorBuilder <T> create (@Nonnull final Class <T> aClass)
  {
    return new UBL21ValidatorBuilder <> (aClass);
  }
1203801
@Nonnull
  public static <T> UBLPEWriterBuilder <T> create (@Nonnull final Class <T> aClass)
  {
    return new UBLPEWriterBuilder <> (aClass);
  }
715508
public static <T> ParameterBuilder<T> create(String name, Class<T> type) {
    return new ParameterBuilder<T>()
        .name(name)
        .type(type);
  }
382426
@SuppressWarnings("rawtypes")
	public static Object instantiate(Class<?> type) throws Exception {
		if (type.isAssignableFrom(ArrayList.class))
			return new ArrayList();
		if (type.isAssignableFrom(LinkedList.class))
			return new LinkedList();
		if (type.isAssignableFrom(HashSet.class))
			return new HashSet();
		if (type.isAssignableFrom(HashMap.class))
			return new HashMap();
		return type.newInstance();
	}
1276479
public static <T> T newInstance(Constructor<T> constructor, Object... args) {
        try {
            return constructor.newInstance(args);
        } catch (Exception e) {
            throw new ClientException(e);
        }
    }
741060
public void create(final Class<T> klass, final int n) {
    for (int i = 0; i != n; i++)
      create(klass);
  }
139627
public static <T> T newBean(Map<?,?> aValues, Class<?> aClass)
	 throws InstantiationException, IllegalAccessException
	 {
		 return newBean(aValues,aClass,null);
	 }
104805
protected Object createObject (Class type) throws InvocationTargetException {
		// Use deferred construction if a non-zero-arg constructor is available.
		DeferredConstruction deferredConstruction = Beans.getDeferredConstruction(type, config);
		if (deferredConstruction != null) return deferredConstruction;
		return Beans.createObject(type, config.privateConstructors);
	}
572628
public static <T> T newInstance(Constructor<T> constructor, Object... args) throws IllegalAccessException, InvocationTargetException, InstantiationException {
        if (constructor.isVarArgs()) {
            args = fixVarArgs(constructor.getParameterTypes(), args);
        }
        return constructor.newInstance(args);
    }
719571
public <T> T newInstance (Class<T> type) {
		Registration registration = getRegistration(type);
		ObjectInstantiator instantiator = registration.getInstantiator();
		if (instantiator == null) {
			instantiator = newInstantiator(type);
			registration.setInstantiator(instantiator);
		}
		return (T)instantiator.newInstance();
	}
214962
public <RET extends Object> RET newInstance(final String iClassName, final Object iEnclosingClass, Object... iArgs) {
		checkSecurity(ODatabaseSecurityResources.CLASS, ORole.PERMISSION_CREATE, iClassName);

		try {
			RET enhanced = (RET) OObjectEntityEnhancer.getInstance().getProxiedInstance(entityManager.getEntityClass(iClassName),
					iEnclosingClass, underlying.newInstance(iClassName), iArgs);
			return (RET) enhanced;
		} catch (Exception e) {
			OLogManager.instance().error(this, "Error on creating object of class " + iClassName, e, ODatabaseException.class);
		}
		return null;
	}
134957
@Nonnull
  public static <T> EbInterfaceValidator <T> create (@Nonnull final Class <T> aClass)
  {
    return new EbInterfaceValidator <> (aClass);
  }
410508
public T create(final Class<T> klass) {
    T obj;
    try {
      obj = (T) klass.newInstance();
    }
    catch (IllegalAccessException e) {
      throw new DocrepException(e);
    }
    catch (InstantiationException e) {
      throw new DocrepException(e);
    }
    add(obj);
    return obj;
  }