Creates new empty Bean instance

@param clazz Class description which would be instantiated
@return empty Bean instance
772545
private T createEmpty(Class<?> clazz) {
        T emptyInstance = null;

        if (clazz.isInterface()) {
            throw new IllegalArgumentException("Specified class is an interface: " + clazz.getName());
        }

        try {
            emptyInstance = (T) clazz.newInstance();
        } catch (InstantiationException ex) {
            throw new IllegalArgumentException(clazz.getName() + ". Is it an abstract class?", ex);
        } catch (IllegalAccessException ex) {
            throw new IllegalArgumentException(clazz.getName() + "Is the constructor accessible?", ex);
        }

        return emptyInstance;
    }
1005841
static <T> T newInstance(final Class<?> clazz, final Class<?>[] argumentTypes, final Object[] arguments,
        final Class<T> expectedType) {
        // Precondition checks
        if (clazz == null) {
            throw new IllegalArgumentException("Class must be specified");
        }
        if (argumentTypes == null) {
            throw new IllegalArgumentException("ArgumentTypes must be specified. Use empty array if no arguments");
        }
        if (arguments == null) {
            throw new IllegalArgumentException("Arguments must be specified. Use empty array if no arguments");
        }
        if (expectedType == null) {
            throw new IllegalArgumentException("Expected type must be specified");
        }

        // Get the ctor
        final Constructor<?> constructor;
        try {
            constructor = getConstructor(clazz, argumentTypes);
        } catch (final NoSuchMethodException e) {
            throw new RuntimeException("Could not create new instance of " + clazz + " using ctor argument types "
                + Arrays.asList(argumentTypes), e);
        }

        // Create the instance
        final Object obj;
        try {
            obj = constructor.newInstance(arguments);
        } catch (final Exception e) {
            throw new RuntimeException("Could not create a new instance of " + clazz + " using arguments "
                + Arrays.asList(arguments), e);
        }

        // Cast
        try {
            return expectedType.cast(obj);
        } catch (final ClassCastException cce) {
            // Reconstruct so we get some useful information
            throw new ClassCastException("Incorrect expected type, " + expectedType.getName() + ", defined for "
                + obj.getClass().getName());
        }
    }
987001
@SuppressWarnings("unchecked")
  public <T extends Entity<?>> T newInstance(final Class<T> clazz) {
    return (T) getEntityType(clazz).newInstance();
  }
467659
public static <T> T newInstance(Class clazz, Object... args) {

        if (clazz == null) return null;

        Class[] argsClass = getArgsClasses(args);

        try {
            Constructor<T> constructor = clazz.<T>getConstructor(argsClass);
            return constructor.newInstance(args);
        } catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
707837
private static Object newInstance(Class<?> clazz) {
        Object instance = null;
        try {
            instance = clazz.newInstance();
        } catch (Exception ex) {
            log.error("Error loading class: {}", clazz.getName(), ex);
        }
        return instance;
    }
43977
protected Constructor<?> getConstructor(Class<?> clazz, Class<?> paramClass) {
        for (Constructor<?> c : clazz.getConstructors()) {
            Class<?>[] paramTypes = c.getParameterTypes();
            if (paramTypes.length != 1) {
                continue;
            }
            if (paramTypes[0].equals(paramClass)) {
                return c;
            }
        }
        return null;
    }
1133911
public static Constructor<?> getEmptyConstructor(Class<?> clazz) {
        Constructor<?> c = clazz.getDeclaredConstructors()[0];
        for (int i = 0; i < clazz.getDeclaredConstructors().length; i++) {
            if (clazz.getDeclaredConstructors()[i].getParameterTypes().length < 1) {
                c = clazz.getDeclaredConstructors()[i];
                break;
            }
        }

        return c;
    }
374328
public static <T> Releasable<T> inject(final Class<T> clazz) {
        try {
            final BeanManager beanManager = CDI.current().getBeanManager();
            if (beanManager == null) {
                return null;
            }
            final AnnotatedType<T> annotatedType = beanManager.createAnnotatedType(clazz);
            final InjectionTarget<T> it = beanManager.createInjectionTarget(annotatedType);
            final CreationalContext<T> context = beanManager.createCreationalContext(null);
            final T instance = it.produce(context);
            it.inject(instance, context);
            it.postConstruct(instance);

            return new Releasable<T>(context, it, instance);
        } catch (final Exception e) {
            // no-op
        } catch (final NoClassDefFoundError error) {
            // no-op
        }
        return null;
    }
903663
public <T> T toBeanIgnoreCase(Class<T> clazz) {
		return BeanUtil.mapToBeanIgnoreCase(this, clazz, false);
	}
1080813
public <T extends Entity<ID>, ID extends Serializable> T newInstance(final Class<T> clazz, final ID id) {
    EntityType type = getEntityType(clazz);
    @SuppressWarnings("unchecked")
    T entity = (T) type.newInstance();
    try {
      PropertyUtils.setProperty(entity, type.getIdName(), id);
    } catch (Exception e) {
      logger.error("initialize {} with id {} error", clazz, id);
    }
    return entity;
  }
1258732
public Bean<T> create() {
        if (!passivationCapable) {
            return new ImmutableBean<T>(beanClass, name, qualifiers, scope, stereotypes, types, alternative, nullable, injectionPoints, beanLifecycle, toString);
        } else {
            return new ImmutablePassivationCapableBean<T>(id, beanClass, name, qualifiers, scope, stereotypes, types, alternative, nullable, injectionPoints, beanLifecycle, toString);
        }
    }
218082
public Marshaller createMarshaller(Class<?> clazz) throws JAXBException {
    Marshaller marshaller = getContext(clazz).createMarshaller();
    setMarshallerProperties(marshaller);
    return marshaller;
  }
1098234
public C createObject(String className, Class clazz) throws ClassNotFoundException {
        return createObject(className, clazz, /* no dynamic init */ null);
    }
535047
public static SgClass create(final SgClassPool pool, final Class<?> clasz) {
        if (pool == null) {
            throw new IllegalArgumentException("The argument 'pool' cannot be null!");
        }
        if (clasz == null) {
            throw new IllegalArgumentException("The argument 'clasz' cannot be null!");
        }

        final SgClass cached = pool.get(clasz.getName());
        if (cached != null) {
            return cached;
        }

        try {

            final SgClass cl = createClass(pool, clasz);
            addInterfaces(pool, cl, clasz);
            addFields(pool, cl, clasz);
            addConstructors(pool, cl, clasz);
            addMethods(pool, cl, clasz);
            addInnerClasses(pool, cl, clasz);
            return cl;

        } catch (final RuntimeException ex) {
            System.out.println("ERROR CLASS: " + clasz);
            throw ex;
        }

    }
1017896
public static <T> Clazz<T> Clazz( Class<T> clazz )
	{
		return impl.Clazz( clazz );
	}
892728
@SuppressWarnings("unchecked")
	public static <T> T newInstance(String clazz) throws UtilException {
		try {
			return (T) Class.forName(clazz).newInstance();
		} catch (Exception e) {
			throw new UtilException(e, "Instance class [{}] error!", clazz);
		}
	}
473992
public static <T> Optional<T> toBean(String json, Class<T> clazz) {
        if (StringUtils.isBlank(json)) {
            log.warn("json is blank. ");
            return Optional.empty();
        }
        try {
            OBJECT_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            return Optional.of(OBJECT_MAPPER.readValue(json, clazz));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return Optional.empty();
        }
    }