Class CachedConfigValue<T>
- java.lang.Object
-
- cc.carm.lib.configuration.value.ValueManifest<T>
-
- cc.carm.lib.configuration.value.ConfigValue<T>
-
- cc.carm.lib.configuration.value.impl.CachedConfigValue<T>
-
- Direct Known Subclasses:
ConfiguredList,ConfiguredMap,ConfiguredValue
public abstract class CachedConfigValue<T> extends ConfigValue<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected TcachedValueprotected longparsedTime-
Fields inherited from class cc.carm.lib.configuration.value.ValueManifest
defaultSupplier, holder, initializer, path, type
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCachedConfigValue(@NotNull ValueManifest<T> manifest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancacheExpired()protected TgetCachedOrDefault()Get the cached value or the default value if the cached value is nullprotected TgetCachedOrDefault(T emptyValue)Get the cached value or the default value if the cached value is nullTgetCachedValue()protected TgetDefaultFirst(T value)protected <O> @Nullable ValueParser<O>parserFor(@NotNull ValueAdapter<O> adapter)protected <O> @Nullable ValueSerializer<O>serializerFor(@NotNull ValueAdapter<O> adapter)protected TupdateCache(T value)-
Methods inherited from class cc.carm.lib.configuration.value.ConfigValue
get, getNotNull, getOrDefault, isDefault, optional, resolve, save, set, setDefault, setDefault
-
Methods inherited from class cc.carm.lib.configuration.value.ValueManifest
config, defaults, defaults, defaults, getData, hasDefaults, holder, holder, initialize, initialize, metadata, path, path, setData, type
-
-
-
-
Field Detail
-
cachedValue
@Nullable protected T cachedValue
-
parsedTime
protected long parsedTime
-
-
Constructor Detail
-
CachedConfigValue
protected CachedConfigValue(@NotNull @NotNull ValueManifest<T> manifest)
-
-
Method Detail
-
getCachedValue
@Nullable public T getCachedValue()
-
cacheExpired
public boolean cacheExpired()
-
getCachedOrDefault
@Nullable protected T getCachedOrDefault()
Get the cached value or the default value if the cached value is null- Returns:
- the cached value or the default value
-
getCachedOrDefault
@Contract("!null->!null") protected T getCachedOrDefault(@Nullable T emptyValue)Get the cached value or the default value if the cached value is null- Parameters:
emptyValue- the value to return if the cached value and the default value are null- Returns:
- the cached value or the default value
-
parserFor
@Nullable protected <O> @Nullable ValueParser<O> parserFor(@NotNull @NotNull ValueAdapter<O> adapter)
- Type Parameters:
O- Base object type- Parameters:
adapter- Value adapter- Returns:
- Value's parser, parse base object to value.
-
serializerFor
@Nullable protected <O> @Nullable ValueSerializer<O> serializerFor(@NotNull @NotNull ValueAdapter<O> adapter)
- Type Parameters:
O- Base object type- Parameters:
adapter- Value adapter- Returns:
- Value's serializer, parse value to base object.
-
-