#870: AutoCompletionUtils.kt

projectforge-business/src/main/kotlin/org/projectforge/business/common/AutoCompletionUtils.kt Type: Utility (object + companion) · Purpose: String search/filter for autocomplete · Source: projectforge-business/src/main/kotlin/org/projectforge/business/common/AutoCompletionUtils.kt 47 lines · 22 code · 22 comments · 3 blank
Provides a simple, case-insensitive multi-word search filter for autocomplete and suggestion UIs. Splits the search query on whitespace, then returns only strings from the input list that contain all search tokens.

API

filter(list: List<String>?, search: String?): List<String>

@JvmStatic public entry point.

containsAll(str: String, strings: List<String>): Boolean

internal helper. Iterates over token list; returns false as soon as any token is not found in str (ignoring case). Returns true if all tokens match.

Design Rationale

The multi-word AND-filter design is suited for autocomplete where users type multiple terms (e.g., "project acme" matching "Acme Project 2024"). The internal visibility of containsAll keeps the inner logic testable within the module without exposing it. The @JvmStatic annotation ensures Java callers can use AutoCompletionUtils.filter(...) without accessing the companion object.

This filter performs a naive substring match (String.contains), not tokenized or prefix-based matching. It is suitable for small-to-medium datasets loaded client-side but may not scale for large datasets.

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.
5f7ef41b8 Copyright 2021 -> 2022
d875be4d4 TimesheetDao: Java - Kotlin
ceb63e8a1 Source code header: (C) 2001-2021.
7c79f1922 Copyright of source header -> 2020.
73a9755df More code cleanup (collapsed catch blocks, replaced deprecated classes, Collections.sort -> List.sort)
000ca723d Remove pointless boolean expressions (business)
dd5ca38ac CopyRight of all java file-header updated or created.