@Override public Optional<Class<? extends Component>> getNavigationTarget( String pathString, List<String> segments) { if (getConfiguration().hasRoute(pathString, segments)) { return getConfiguration().getRoute(pathString, segments); } return Optional.empty(); }
/** * Check if there are registered navigation targets in the registry. * * @return true if any navigation are registered */ public boolean hasNavigationTargets() { return !getConfiguration().getRoutes().isEmpty(); }
/** * Set error handler navigation targets. * <p> * This can also be used to add error navigation targets that override * existing targets. Note! The overriding targets need to be extending the * existing target or they will throw. * * @param errorNavigationTargets * error handler navigation targets */ public void setErrorNavigationTargets( Set<Class<? extends Component>> errorNavigationTargets) { Map<Class<? extends Exception>, Class<? extends Component>> exceptionTargetsMap = new HashMap<>(); exceptionTargetsMap.putAll(getConfiguration().getExceptionHandlers()); errorNavigationTargets.stream() .filter(target -> !defaultErrorHandlers.contains(target)) .filter(this::allErrorFiltersMatch) .forEach(target -> addErrorTarget(target, exceptionTargetsMap)); initErrorTargets(exceptionTargetsMap); }
/** * Get a registered navigation target for given exception. First we will * search for a matching cause for in the exception chain and if no match * found search by extended type. * * @param exception * exception to search error view for * @return optional error target entry corresponding to the given exception */ public Optional<ErrorTargetEntry> getErrorNavigationTarget( Exception exception) { if (getConfiguration().getExceptionHandlers().isEmpty()) { initErrorTargets(new HashMap<>()); } Optional<ErrorTargetEntry> result = searchByCause(exception); if (!result.isPresent()) { result = searchBySuperType(exception); } return result; }