/** * Requires the current {@link ViewNavigator}. If not available using {@link #getCurrent()}, an * {@link IllegalStateException} is thrown. * @return Current ViewNavigator * @throws IllegalStateException ViewNavigator is not available as a {@link Context} resource of from current UI */ static ViewNavigator require() { return getCurrent().orElseThrow(() -> new IllegalStateException( "ViewNavigator is not available as context resource or from current UI")); }
public void obtain() { // tag::obtain[] Optional<ViewNavigator> navigator = ViewNavigator.getCurrent(); // <1> ViewNavigator viewNavigator = ViewNavigator.require(); // <2> // end::obtain[] }