ru.astrainteractive.astralibs.util.StringListExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Core utilities for spigot development
package ru.astrainteractive.astralibs.util
object StringListExt {
/**
* If you have list with entries {"entry","ementry","emementry"} and entry="me",
* you'll have returned list {"ementry","emementry"}.
*
* Very useful for TabCompleter
*
*/
fun List.withEntry(entry: String?, ignoreCase: Boolean = true): List {
if (entry == null) return this
return filter { item -> item.contains(other = entry, ignoreCase = ignoreCase) }
}
}