Package net.morimekta.providence.config
Interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
-
- All Superinterfaces:
java.util.function.Supplier<M>
- All Known Implementing Classes:
FixedConfigSupplier
,OverrideConfigSupplier
,ProvidenceConfigSupplier
,ReferenceConfigSupplier
,ResourceConfigSupplier
,TestConfigSupplier
,UpdatingConfigSupplier
public interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField> extends java.util.function.Supplier<M>
A supplier and instance holder for config objects. This supplier can be listened to for changes in the config object. When something triggers a change (supplier.set(config)
) that will cause a config change call to each listener regardless of if the config values actually did change.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addListener(ConfigListener<M,F> listener)
Add a listener to changes to this config.long
configTimestamp()
Get the last update time as a millisecond timestamp.java.lang.String
getName()
Get a simple descriptive name for this config supplier.void
removeListener(ConfigListener<M,F> listener)
Remove a config change listener.default ConfigSupplier<M,F>
snapshot()
Get a snapshot of the current config.
-
-
-
Method Detail
-
addListener
void addListener(@Nonnull ConfigListener<M,F> listener)
Add a listener to changes to this config. Note that this will store a weak reference to the listener instance, so the one adding the listener must make sure the listener is not GC'd.- Parameters:
listener
- The config change listener to be added.
-
removeListener
void removeListener(@Nonnull ConfigListener<M,F> listener)
Remove a config change listener.- Parameters:
listener
- The config change listener to be removed.
-
getName
java.lang.String getName()
Get a simple descriptive name for this config supplier.- Returns:
- The supplier name.
-
configTimestamp
long configTimestamp()
Get the last update time as a millisecond timestamp.- Returns:
- The timestamp of last update of the config.
-
snapshot
default ConfigSupplier<M,F> snapshot()
Get a snapshot of the current config.- Returns:
- Non-modifiable supplier of current config containing a snapshot.
-
-