Gets object instance from groovy resource.

@param <T>          the type parameter
@param resource     the resource
@param expectedType the expected type
@return the object instance from groovy resource
511762
public static <T> T getObjectInstanceFromGroovyResource(final Resource resource,
                                                            final Class<T> expectedType) {
        return getObjectInstanceFromGroovyResource(resource, ArrayUtils.EMPTY_CLASS_ARRAY, ArrayUtils.EMPTY_OBJECT_ARRAY, expectedType);
    }
1273997
public static ParamProcessor newInstance(ParamType type, String listSeparator){
        switch(type){
            case COOKIE:
                return listSeparator != null ? new CollectionMergingCookieParamProcessor(listSeparator) : DefaultCookieParamProcessor.INSTANCE;
            default:
                return listSeparator != null ? new CollectionMergingParamProcessor(listSeparator) : DefaultParamProcessor.INSTANCE;
        }
    }
510212
public static boolean isExpectedType(final Class<?> expectedClass, final Object obj) {
        final Class<?> actualClass;
        if (obj == null) {
            actualClass = null;
        } else {
            actualClass = obj.getClass();
        }
        return Objects.equals(expectedClass, actualClass);
    }
862207
@SuppressWarnings("unchecked")
  private static <T> T newInstance(Class<?> type) {
    try {
      return (T) type.newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      throw new ServiceException("Cannot instantiate service class " + type, e);
    }
  }
604665
public <T> T createInstance(Class<T> type) {
        try {
            return type.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new IllegalArgumentException("Cannot create instance of class " + type.getName(), e);
        }
    }
294207
public static String readFromResource(String resource) throws IOException {

        InputStream in = getResourceAsStream(resource);
        if (in == null) {
            return null;
        }
        try {
            return read(in);
        } finally {
            closeQuietly(in);
        }
    }
698603
public <T> T lookup(String name, Class<T> expectedType) throws Throwable
   {
      if (name == null)
         throw new IllegalArgumentException("Name is null");

      if (expectedType == null)
         throw new IllegalArgumentException("ExpectedType is null");

      if (!started)
         throw new IllegalStateException("Container not started");

      return kernel.getBean(name, expectedType);
   }
117301
public <T> T loadResources(Class<T> type, List<String> resources) {
    if (resources == null || resources.isEmpty()) {
      throw new IllegalArgumentException("resources must be defined");
    }
    Config config = null;
    for (String resource : resources) {
      if (config == null) {
        config = ConfigFactory.load(classLoader, resource);
      } else {
        config = config.withFallback(ConfigFactory.load(classLoader, resource));
      }
    }
    return map(checkNotNull(config, "config cannot be null").resolve(), type);
  }
501357
public final static <T extends FastSerializable> T deserialize(
            final byte[] data, final Class<T> expectedType) throws IOException {
        final FastDeserializer in = new FastDeserializer(data);
        return in.readObject(expectedType);
    }
747651
private Resource<T> translateResourceExternal(Resource<T> resource) {
        if (fullPath) {
            return resource;
        }
        return new translatedResource<T>(resource, translatePathExternal(resource.getPath()));
    }
756502
protected GsonJsonEngine createGsonJsonEngine(JsonEngineResource resource) {
        final boolean serializeNulls = isGsonSerializeNulls();
        final boolean prettyPrinting = isGsonPrettyPrinting();
        final Consumer<GsonBuilder> builderSetupper = prepareGsonBuilderSetupper(serializeNulls, prettyPrinting);
        final Consumer<JsonMappingOption> optionSetupper = prepareMappingOptionSetupper(resource.getMappingOption());
        return resource.getYourEngineCreator().map(creator -> { // rare option
            return createYourEngine(creator, builderSetupper, optionSetupper);
        }).orElseGet(() -> { // mainly here
            return newGsonJsonEngine(builderSetupper, optionSetupper);
        });
    }
699215
public static Node getJcrNode(final FedoraResource resource) {
        if (resource instanceof FedoraResourceImpl) {
            return ((FedoraResourceImpl)resource).getNode();
        }
        throw new IllegalArgumentException("FedoraResource is of the wrong type");
    }
146386
public static Properties loadFromResource(ServletContext servletContext, String resource) throws IOException {
		Properties props = new Properties();
		InputStream in = servletContext.getResourceAsStream(resource);
		if(in==null) throw new LocalizedIOException(accessor, "PropertiesUtils.readProperties.resourceNotFound", resource);
		try {
			props.load(in);
		} finally {
			in.close();
		}
		return props;
	}
1332993
public static <T> T newInstance(Type type) {
        try {
            Class<T> clazz = (Class<T>) getClass(type);
            if (clazz == null) {
                return null;
            }
            return clazz.newInstance();
        } catch (Exception e) {
            log.warn("new instance fail :{}", e.getCause().toString());
            throw new NewInstanceException(e.getCause().toString());
        }
    }
965986
public static synchronized I18n getI18n(String resource) {
        I18n instance = (I18n)mapping.get(resource);
        if (instance == null) {
            instance = new I18n(ResourceBundle.getBundle(resource,
                                                         Locale.getDefault(),
                                                         getClassLoader()));
            mapping.put(resource, instance);
        }
        return instance;
    }
689619
public ResourceMetaData getResourceMetaData(Resource resource)
    {
        Object o=resource.getAssociate();
        if (o instanceof ResourceMetaData)
            return (ResourceMetaData)o;
        return new ResourceMetaData(resource);
    }
329040
public static SeLionDataProvider getDataProvider(DataResource resource)
            throws IOException {
        logger.entering(resource);

        if(resource == null) {
            return null;
        }

        switch (resource.getType().toUpperCase()) {
        case "XML":
            return new XmlDataProviderImpl((XmlDataSource) resource);
        case "JSON":
            return new JsonDataProviderImpl(resource);
        case "YAML":
        case "YML":
            return new YamlDataProviderImpl(resource);
        case "XLSX":
        case "XLS":
            return new ExcelDataProviderImpl(resource);
        default:
            return null;
        }
     }