Interface InstanceInitializer
-
- All Known Implementing Classes:
AbstractInstanceInitializer
,DebuggerInstanceInitializer
,DecoderIndexFile.Initializer
,DefaultCatalogTreeManager.Initializer
,DefaultIdTagManager.Initializer
,DefaultInstanceInitializer
,DeferringProgrammerManager.Initializer
,EngineModels.Initializer
,ImageIndexEditor.Initializer
,JmriUserPreferencesManager.Initializer
,LogixNG_AnalogInstanceInitializer
,LogixNG_DigitalInstanceInitializer
,LogixNG_InstanceInitializer
,LogixNG_StringInstanceInitializer
,NameFile.Initializer
,PermissionInstanceInitializer
,Server.Initializer
,ServerFrame.Initializer
,ShutDownManagerInitializer
,TrackerTableAction.Initializer
,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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> java.lang.Object
getDefault(java.lang.Class<T> type)
Provide a default instance of the given class.java.util.Set<java.lang.Class<?>>
getInitalizes()
Get the set of classes for which this InstanceInitializer can provide default instances for.
-
-
-
Method Detail
-
getDefault
@Nonnull <T> java.lang.Object getDefault(@Nonnull java.lang.Class<T> type)
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:
java.lang.IllegalArgumentException
- if creating an instance of type is not supported by this InstanceInitalizer
-
getInitalizes
@Nonnull java.util.Set<java.lang.Class<?>> 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.
-
-