Class FixedConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>

  • All Implemented Interfaces:
    java.util.function.Supplier<M>, ConfigSupplier<M,F>
    Direct Known Subclasses:
    ResourceConfigSupplier

    @Immutable
    public class FixedConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
    extends java.lang.Object
    implements ConfigSupplier<M,F>
    A supplier and instance holder for an immutable config instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      FixedConfigSupplier​(M initialConfig)
      Initialize with an initial config instance.
      FixedConfigSupplier​(M initialConfig, long timestamp)
      Initialize with an initial config instance.
      FixedConfigSupplier​(ConfigSupplier<M,F> supplier)
      This essentially makes a static snapshot of the config and keeps the config instance as a fixed (unmodifiable) config.
    • Constructor Detail

      • FixedConfigSupplier

        public FixedConfigSupplier​(@Nonnull
                                   M initialConfig)
        Initialize with an initial config instance.
        Parameters:
        initialConfig - The initial config instance.
      • FixedConfigSupplier

        public FixedConfigSupplier​(@Nonnull
                                   ConfigSupplier<M,F> supplier)
        This essentially makes a static snapshot of the config and keeps the config instance as a fixed (unmodifiable) config.
        Parameters:
        supplier - The config supplier to copy.
      • FixedConfigSupplier

        public FixedConfigSupplier​(@Nonnull
                                   M initialConfig,
                                   long timestamp)
        Initialize with an initial config instance.
        Parameters:
        initialConfig - The initial config instance.
        timestamp - The config timestamp.
    • Method Detail

      • get

        @Nonnull
        public final M get()
        Specified by:
        get in interface java.util.function.Supplier<M extends net.morimekta.providence.PMessage<M,F>>
      • addListener

        public final void addListener​(@Nonnull
                                      ConfigListener<M,F> listener)
        Description copied from interface: ConfigSupplier
        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.
        Specified by:
        addListener in interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
        Parameters:
        listener - The config change listener to be added.
      • removeListener

        public final void removeListener​(@Nonnull
                                         ConfigListener<M,F> listener)
        Description copied from interface: ConfigSupplier
        Remove a config change listener.
        Specified by:
        removeListener in interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
        Parameters:
        listener - The config change listener to be removed.
      • configTimestamp

        public long configTimestamp()
        Description copied from interface: ConfigSupplier
        Get the last update time as a millisecond timestamp.
        Specified by:
        configTimestamp in interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
        Returns:
        The timestamp of last update of the config.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getName

        public java.lang.String getName()
        Description copied from interface: ConfigSupplier
        Get a simple descriptive name for this config supplier.
        Specified by:
        getName in interface ConfigSupplier<M extends net.morimekta.providence.PMessage<M,F>,F extends net.morimekta.providence.descriptor.PField>
        Returns:
        The supplier name.