/** * Filters a given installation category * * @param installationCategory The to be filtered installation category * @return True if the installation category should be shown, false otherwise */ public boolean filter(InstallationCategoryDTO installationCategory) { return Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> installationCategory.getInstallations().stream().anyMatch(this::filter)) .orElse(true); }
/** * Filters a given shortcut category * * @param shortcutCategory The to be filtered shortcut category * @return True if the shortcut category should be shown, false otherwise */ public boolean filter(ShortcutCategoryDTO shortcutCategory) { return Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> shortcutCategory.getShortcuts().stream().anyMatch(this::filter)) .orElse(true); }
/** * Filters a given container category * * @param containerCategory The to be filtered container category * @return True if the container category should be shown, false otherwise */ public boolean filter(ContainerCategoryDTO containerCategory) { return Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> containerCategory.getContainers().stream().anyMatch(this::filter)) .orElse(true); }
/** * Filters a given container * * @param installation The to be filtered container * @return True if the container should be shown, false otherwise */ public boolean filter(ContainerDTO installation) { final boolean searchTermConstraint = Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> installation.getName().toLowerCase().contains(searchTerm.toLowerCase())) .orElse(true); final boolean selectedContainerCategoryConstraint = Optional.ofNullable(selectedContainerCategory.getValue()) .map( selectedContainerCategory -> selectedContainerCategory.getContainers().contains(installation)) .orElse(true); return searchTermConstraint && selectedContainerCategoryConstraint; }
/** * Checks if the given engine category fulfills this filter * * @param engineCategory The engine category * @return True if the given engine category fulfills the filter, false otherwise */ public boolean filter(EngineCategoryDTO engineCategory) { return Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> engineCategory.getSubCategories().stream() .anyMatch(engineSubCategory -> engineSubCategory.getPackages().stream() .anyMatch(version -> version.getVersion().toLowerCase() .contains(searchTerm.toLowerCase())))) .orElse(true); }
/** * Filters a given shortcut * * @param shortcut The to be filtered shortcut * @return True if the shortcut should be shown, false otherwise */ public boolean filter(ShortcutDTO shortcut) { final boolean searchTermConstraint = Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> shortcut.getInfo().getName().toLowerCase().contains(searchTerm.toLowerCase())) .orElse(true); final boolean selectedShortcutCategoryConstraint = Optional.ofNullable(selectedShortcutCategory.getValue()) .map(selectedShortcutCategory -> selectedShortcutCategory.getShortcuts().contains(shortcut)) .orElse(true); return searchTermConstraint && selectedShortcutCategoryConstraint; }
/** * Filters a given installation * * @param installation The to be filtered installation * @return True if the installation should be shown, false otherwise */ public boolean filter(InstallationDTO installation) { final boolean searchTermConstraint = Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> installation.getName().toLowerCase().contains(searchTerm.toLowerCase())) .orElse(true); final boolean selectedInstallationCategoryConstraint = Optional .ofNullable(selectedInstallationCategory.getValue()) .map(selectedShortcutCategory -> selectedShortcutCategory.getInstallations().contains(installation)) .orElse(true); return searchTermConstraint && selectedInstallationCategoryConstraint; }
/** * Creates a new filter predicate for a {@link EngineCategoryDTO} and {@link EngineSubCategoryDTO}. * This predicate then accepts a {@link EngineVersionDTO} object and returns true if the given object fulfills the * filter predicate and false otherwise * * @param engineCategory The engine category * @param engineSubCategory The engine sub category * @return A new filter predicate */ public Predicate<EngineVersionDTO> createFilter(EngineCategoryDTO engineCategory, EngineSubCategoryDTO engineSubCategory) { return engineVersion -> { final boolean containsSearchTerm = Optional.ofNullable(searchTerm.getValueSafe()) .map(searchTerm -> engineVersion.getVersion().toLowerCase().contains(searchTerm.toLowerCase())) .orElse(true); final boolean fulfillsShowInstalled = showInstalled.getValue() && isInstalled(engineCategory, engineSubCategory, engineVersion); final boolean fulfillsShowNotInstalled = showNotInstalled.getValue() && !isInstalled(engineCategory, engineSubCategory, engineVersion); return containsSearchTerm && (fulfillsShowInstalled || fulfillsShowNotInstalled); }; }