@Mutable public final class InstanceCache extends Object
InstanceUtils,
InstanceCacheAware| 限定符和类型 | 方法和说明 |
|---|---|
InstanceCache |
add(Class<?> type,
Object instance)
用户初始化缓存
|
<T> T |
findOrCreate(Class<?> type)
查找或尝试创建对象
|
<T> T |
findOrCreate(Class<?> type,
Supplier<? extends RuntimeException> exceptionIfCannotCreateInstance)
查找或尝试创建对象
|
static InstanceCache |
newInstance()
创建实例缓存实例
|
static InstanceCache |
newInstance(org.springframework.context.ApplicationContext applicationContext)
创建实例缓存实例
|
public static InstanceCache newInstance()
public static InstanceCache newInstance(@Nullable org.springframework.context.ApplicationContext applicationContext)
applicationContext - Spring上下文,可为 nullpublic InstanceCache add(Class<?> type, Object instance)
type - 要缓存的类型 (不可为null)instance - 实例 (不可为null)public <T> T findOrCreate(Class<?> type)
T - 实例泛型type - 实例的类型public <T> T findOrCreate(Class<?> type, Supplier<? extends RuntimeException> exceptionIfCannotCreateInstance)
T - 实例泛型type - 实例的类型exceptionIfCannotCreateInstance - 在尝试创建对象失败时异常提供器Copyright © 2022. All rights reserved.