Package ej.navigation

Interface PageFactory

    • Method Detail

      • create

        Page create​(int key,
                    @Nullable
                    Object argument)
             throws IllegalArgumentException
        Creates the page identified by the given key, injecting the given per-navigation argument.

        Called by the navigator when a navigation pushes a new history entry (Navigator.navigateTo(int)) or replaces the active one (Navigator.replaceWith(int)); it is not called on back navigation, which re-shows the cached page. A fresh page is expected on each call; the returned page must not be null.

        The argument is the one the navigation carried, and is null when it carried none. A factory that resolves a key expecting an argument is responsible for checking what it received: the navigator neither inspects the argument nor matches it against the key.

        Parameters:
        key - the non-negative key of the page to create.
        argument - the argument the navigation carried, or null if it carried none.
        Returns:
        the page for the given key.
        Throws:
        IllegalArgumentException - if the given key does not identify any page.