Convenience method used to create a new instance of a table builder.<p>

@param cls the bean class
@return the new table builder
166129
public static <V> CmsBeanTableBuilder<V> newInstance(Class<V> cls) {

        return new CmsBeanTableBuilder<V>(cls, null);

    }
583932
public <X> X cast(final Class<X> cls) {
        if (cls == null) {
            throw new IllegalArgumentException("Parameter 'cls' muss angegeben werden");
        }

        final Class<?> beanClass = bean.getClass();
        if (cls.isAssignableFrom(beanClass)) {
            return cls.cast(bean);
        }
        throw new ClassCastException("Klasse " + beanClass + " kann nicht nach " + cls + " gewandelt werden");
    }
1222229
public static <T> T  toBean(String xmlStr,Class<T> cls){
        //注意：不是new Xstream(); 否则报错：java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserFactory
        XStream xstream= new XStream(new DomDriver());
        xstream.processAnnotations(cls);
        T obj=(T)xstream.fromXML(xmlStr);
        return obj;
    }
1161306
public static AnnotationInfo.Builder createAnnotation(Class<? extends Annotation> clazz) {
        return AnnotationInfo.builder(valueFormatter).name(clazz);
    }
932162
<T> DynamoDBTable getTable(Class<T> clazz) {
        DynamoDBTable table = clazz.getAnnotation(DynamoDBTable.class);
        if ( table == null )
            throw new DynamoDBMappingException("Class " + clazz + " must be annotated with " + DynamoDBTable.class);
        return table;
    }
1054037
public static <T> T newInstance(final Class<T> clas) {
		try {
			return clas.newInstance();
		} catch (final Exception e) {
			throw new RuntimeException(e);
		}

	}
1294574
public static <T> Parameters.Builder<T> logger(Class<?> cls) {
        return Parameters.<T> builder().logger(cls);
    }
135894
public static org.opencms.db.generic.CmsSqlManager getInstance(String classname) {

        org.opencms.db.generic.CmsSqlManager sqlManager;

        try {
            Object objectInstance = Class.forName(classname).newInstance();
            sqlManager = (org.opencms.db.generic.CmsSqlManager)objectInstance;
        } catch (Throwable t) {
            LOG.error(Messages.get().getBundle().key(Messages.LOG_SQL_MANAGER_INIT_FAILED_1, classname), t);
            sqlManager = null;
        }

        if (CmsLog.INIT.isInfoEnabled()) {
            CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_DRIVER_SQL_MANAGER_1, classname));
        }

        return sqlManager;

    }
485697
public SqlBuilder newFrom(final String from) {
    if (null == from) {
      this.from = null;
    } else {
      if (Strings.contains(from.toLowerCase(), "from")) {
        this.from = from;
      } else {
        this.from = " from " + from;
      }
    }
    return this;
  }
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);
        }
    }
222320
public static Builder newBuilder(TableId table, RowToInsert... rows) {
    return newBuilder(table, ImmutableList.copyOf(rows));
  }
1220152
public static <T> T newInstance(final Class<T> cls) {
        if (Modifier.isAbstract(cls.getModifiers())) {
            if (cls.equals(Map.class)) {
                return (T) new HashMap<>();
            } else if (cls.equals(List.class)) {
                return (T) new ArrayList<>();
            } else if (cls.equals(Set.class)) {
                return (T) new HashSet<>();
            } else if (cls.equals(Queue.class)) {
                return (T) new LinkedList<>();
            } else if (cls.equals(Deque.class)) {
                return (T) new LinkedList<>();
            } else if (cls.equals(SortedSet.class) || cls.equals(NavigableSet.class)) {
                return (T) new TreeSet<>();
            } else if (cls.equals(SortedMap.class) || cls.equals(NavigableMap.class)) {
                return (T) new TreeMap<>();
            }
        }

        try {
            if (Modifier.isStatic(cls.getModifiers()) == false && (cls.isAnonymousClass() || cls.isMemberClass())) {
                // http://stackoverflow.com/questions/2097982/is-it-possible-to-create-an-instance-of-nested-class-using-java-reflection

                final List<Class<?>> toInstantiate = new ArrayList<>();
                Class<?> parent = cls.getEnclosingClass();

                do {
                    toInstantiate.add(parent);
                    parent = parent.getEnclosingClass();
                } while (parent != null && Modifier.isStatic(parent.getModifiers()) == false && (parent.isAnonymousClass() || parent.isMemberClass()));

                if (parent != null) {
                    toInstantiate.add(parent);
                }

                N.reverse(toInstantiate);

                Object instance = null;
                for (Class<?> current : toInstantiate) {
                    instance = instance == null ? invoke(ClassUtil.getDeclaredConstructor(current))
                            : invoke(ClassUtil.getDeclaredConstructor(current, instance.getClass()), instance);
                }

                return invoke(ClassUtil.getDeclaredConstructor(cls, instance.getClass()), instance);
            } else {
                return invoke(ClassUtil.getDeclaredConstructor(cls));
            }
        } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
            throw N.toRuntimeException(e);
        }
    }
570656
public static Builder newBuilder(TableId destinationTable, List<TableId> sourceTables) {
    return new Builder().setDestinationTable(destinationTable).setSourceTables(sourceTables);
  }
28599
public static ClassLoader getClassLoader(Class<?> cls) {
        ClassLoader cl = cls.getClassLoader();
        if (cl == null) {
            cl = getClassLoader();
        }
        return cl;
    }
125316
public RTMPConnection createConnectionInstance(Class<?> cls) throws Exception {
        RTMPConnection conn = null;
        if (cls == RTMPMinaConnection.class) {
            conn = (RTMPMinaConnection) cls.newInstance();
        } else if (cls == RTMPTClientConnection.class) {
            conn = (RTMPTClientConnection) cls.newInstance();
        } else {
            conn = (RTMPConnection) cls.newInstance();
        }
        conn.setMaxHandshakeTimeout(maxHandshakeTimeout);
        conn.setMaxInactivity(maxInactivity);
        conn.setPingInterval(pingInterval);
        if (enableTaskExecutor) {
            // setup executor
            ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
            executor.setCorePoolSize(1);
            executor.setDaemon(true);
            executor.setMaxPoolSize(1);
            executor.setQueueCapacity(executorQueueCapacity);
            executor.initialize();
            conn.setExecutor(executor);
        }
        return conn;
    }
1200002
public static <T> T newInstance(Class<T> clazz, Object... params) throws UtilException {
		if (ArrayUtil.isEmpty(params)) {
			final Constructor<T> constructor = getConstructor(clazz);
			try {
				return constructor.newInstance();
			} catch (Exception e) {
				throw new UtilException(e, "Instance class [{}] error!", clazz);
			}
		}

		final Class<?>[] paramTypes = ClassUtil.getClasses(params);
		final Constructor<T> constructor = getConstructor(clazz, paramTypes);
		if (null == constructor) {
			throw new UtilException("No Constructor matched for parameter types: [{}]", new Object[] { paramTypes });
		}
		try {
			return constructor.newInstance(params);
		} catch (Exception e) {
			throw new UtilException(e, "Instance class [{}] error!", clazz);
		}
	}
429629
@SuppressWarnings("unchecked")
    public <T> T get(Class<T> cls) {
        T runtimeInstance = (T) runtimeServices.computeIfAbsent(cls, this::createRuntimeInstance);
        if (runtimeInstance == null) {
            throw new NoSuchElementException(cls.getName());
        } else {
            return runtimeInstance;
        }
    }