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 T
cachedValue
protected long
parsedTime
-
Fields inherited from class cc.carm.lib.configuration.value.ValueManifest
defaultSupplier, holder, initializer, path, type
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CachedConfigValue(@NotNull ValueManifest<T> manifest)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
cacheExpired()
protected T
getCachedOrDefault()
Get the cached value or the default value if the cached value is nullprotected T
getCachedOrDefault(T emptyValue)
Get the cached value or the default value if the cached value is nullT
getCachedValue()
protected T
getDefaultFirst(T value)
protected <O> @Nullable ValueParser<O>
parserFor(@NotNull ValueAdapter<O> adapter)
protected <O> @Nullable ValueSerializer<O>
serializerFor(@NotNull ValueAdapter<O> adapter)
protected T
updateCache(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.
-
-