Package dev.zemco.codegame.presentation
Class ResourceFxmlViewSourceProvider
java.lang.Object
dev.zemco.codegame.presentation.ResourceFxmlViewSourceProvider
- All Implemented Interfaces:
IFxmlViewSourceProvider
Provides the JavaFX FXML sources from resources of the specified class for specified views.
This implementation's view mappings are immutable.
- Author:
- Erik Zemčík
-
Constructor Summary
ConstructorsConstructorDescriptionResourceFxmlViewSourceProvider(Class<?> resourceClass, Map<String, String> viewIdToFxmlResourcePathMap) Creates an instance ofResourceFxmlViewSourceProvider. -
Method Summary
Modifier and TypeMethodDescriptiongetFxmlViewSourceStreamById(String viewId) Provides aninput streamwith the raw FXML source of the requested view.
-
Constructor Details
-
ResourceFxmlViewSourceProvider
public ResourceFxmlViewSourceProvider(Class<?> resourceClass, Map<String, String> viewIdToFxmlResourcePathMap) Creates an instance ofResourceFxmlViewSourceProvider. The resources are retrieved from the given resource class. The view mappings cannot be modified after the construction.- Parameters:
resourceClass- class to use as source of resourcesviewIdToFxmlResourcePathMap- mappings of view ids to their respective FXML source resources- Throws:
IllegalArgumentException- ifresourceClassisnullor ifviewIdToFxmlResourcePathMapisnull
-
-
Method Details
-
getFxmlViewSourceStreamById
Provides aninput streamwith the raw FXML source of the requested view.The view is identified by the
viewIdparameter, and is resolved through the view mappings given during the construction of the provider. The resource streams are retrieved from the resource class using theClass.getResourceAsStream(String)method.- Specified by:
getFxmlViewSourceStreamByIdin interfaceIFxmlViewSourceProvider- Parameters:
viewId- identification of the view- Returns:
- input stream with the raw FXML source
- Throws:
IllegalArgumentException- ifviewIdisnullor emptyUnknownViewException- when theviewIdis not known by the providerResourceLoadException- if the resource specified by the mappings is not available in the resource class- See Also:
-