Class ReferenceConfigSupplier<RefMessage extends net.morimekta.providence.PMessage<RefMessage>,ParentMessage extends net.morimekta.providence.PMessage<ParentMessage>>
- java.lang.Object
-
- net.morimekta.providence.config.impl.UpdatingConfigSupplier<RefMessage>
-
- net.morimekta.providence.config.impl.ReferenceConfigSupplier<RefMessage,ParentMessage>
-
- All Implemented Interfaces:
java.util.function.Supplier<RefMessage>,ConfigListener<ParentMessage>,ConfigSupplier<RefMessage>
public class ReferenceConfigSupplier<RefMessage extends net.morimekta.providence.PMessage<RefMessage>,ParentMessage extends net.morimekta.providence.PMessage<ParentMessage>> extends UpdatingConfigSupplier<RefMessage> implements ConfigListener<ParentMessage>
A supplier to get a config (aka message) from a resource location. This is a fixed static supplier, so listening to changes will never do anything.ConfigSupplier<Service, Service._Field> supplier = new SerializedConfigSupplier<>(referencePath, Service.kDescriptor);
-
-
Constructor Summary
Constructors Constructor Description ReferenceConfigSupplier(ConfigSupplier<ParentMessage> parent, java.time.Clock clock, net.morimekta.providence.descriptor.PField<?>... fieldRefs)Create a config that wraps a providence message instance, and fetches a message from within that parent config.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetName()Get a simple descriptive name for this config supplier.voidonConfigChange(ParentMessage updated)Called when the config is updated.java.lang.StringtoString()-
Methods inherited from class net.morimekta.providence.config.impl.UpdatingConfigSupplier
addListener, configTimestamp, get, getClock, reference, removeListener, set
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.config.ConfigSupplier
override, override, snapshot
-
-
-
-
Constructor Detail
-
ReferenceConfigSupplier
public ReferenceConfigSupplier(ConfigSupplier<ParentMessage> parent, java.time.Clock clock, net.morimekta.providence.descriptor.PField<?>... fieldRefs) throws ConfigException
Create a config that wraps a providence message instance, and fetches a message from within that parent config. It is not allowed to have it return a null, meaning for the reference config to be valid, the reference must exist.- Parameters:
parent- The message type descriptor.clock- The clock to use for timing.fieldRefs- Fields to reference.- Throws:
ConfigException- If message overriding failed
-
-
Method Detail
-
onConfigChange
public void onConfigChange(@Nonnull ParentMessage updated)Description copied from interface:ConfigListenerCalled when the config is updated. Does not necessary mean the config did change it's values.- Specified by:
onConfigChangein interfaceConfigListener<RefMessage extends net.morimekta.providence.PMessage<RefMessage>>- Parameters:
updated- The new config instance.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getName
public java.lang.String getName()
Description copied from interface:ConfigSupplierGet a simple descriptive name for this config supplier.- Specified by:
getNamein interfaceConfigSupplier<RefMessage extends net.morimekta.providence.PMessage<RefMessage>>- Returns:
- The supplier name.
-
-