Package jmri

Interface InstanceInitializer

All Known Implementing Classes:
AbstractInstanceInitializer, DecoderIndexFile.Initializer, DefaultCatalogTreeManager.Initializer, DefaultIdTagManager.Initializer, DefaultInstanceInitializer, DeferringProgrammerManager.Initializer, EngineModels.Initializer, ImageIndexEditor.Initializer, JmriUserPreferencesManager.Initializer, NameFile.Initializer, Server.Initializer, ServerFrame.Initializer, ShutDownManagerInitializer, TrackerTableAction.Initializer, WebServerPreferencesInstanceInitializer, WiThrottlePreferences.Initializer

public interface InstanceInitializer
Interface providing initialization of specific objects by default. This is used to move references to specific subtypes out of the jmri package and into more specialized packages.

Note that this is only needed when the object can't be created with a no-arguments constructor. In that case, the InstanceManagerAutoDefault mechanism is a better choice.

Instances of this class will normally be used only if they are annotated with @ServiceProvider(service = InstanceInitializer.class)

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Since:
2.9.4
  • Method Summary

    Modifier and Type Method Description
    <T> Object getDefault​(Class<T> type)
    Provide a default instance of the given class.
    Set<Class<?>> getInitalizes()
    Get the set of classes for which this InstanceInitializer can provide default instances for.
  • Method Details

    • getDefault

      Provide a default instance of the given class.

      Note calling this method twice for the same class should not be expected to return the same instance; however, there is no guarantee that the same instance will not be returned for two calls to this method.

      Type Parameters:
      T - the class to get the default for
      Parameters:
      type - the class to get the default for
      Returns:
      the newly created default for the given class
      Throws:
      IllegalArgumentException - if creating an instance of type is not supported by this InstanceInitalizer
    • getInitalizes

      Get the set of classes for which this InstanceInitializer can provide default instances for.
      Returns:
      the set of classes this InstanceInitalizer supports; if empty, getDefault(java.lang.Class) will never be called.