Mercurial > cgi-bin > hgweb.cgi > JpegWasher
diff src/name/blackcap/exifwasher/Whitelist.kt @ 3:19c381c536ec
Code to make it a proper Mac GUI app. Untested!
author | David Barts <n5jrn@me.com> |
---|---|
date | Wed, 08 Apr 2020 20:29:12 -0700 |
parents | efd9fe2d70d7 |
children | dc1f4359659d |
line wrap: on
line diff
--- a/src/name/blackcap/exifwasher/Whitelist.kt Wed Apr 01 14:23:54 2020 -0700 +++ b/src/name/blackcap/exifwasher/Whitelist.kt Wed Apr 08 20:29:12 2020 -0700 @@ -7,7 +7,7 @@ import kotlin.collections.mutableSetOf import kotlin.collections.mutableListOf -class Whitelist { +class Whitelist: Cloneable { private val entire = mutableSetOf<String>() private val prefixes = mutableListOf<String>() @@ -29,17 +29,18 @@ fun contains(s: String) = entire.contains(s) || prefixes.find { s.startsWith(it) } != null - fun toList(): List<String> = mutableListOf<String>().also { - it.addAll(entire) - it.addAll(prefixes) - it.sort() - } + fun toList(): List<String> = prefixes + entire override fun toString(): String = toList().joinToString(",") + override public fun clone() = this().also { new -> + entire.forEach { new.addEntire(it) } + prefixes.forEach { new.addPrefix(it) } + } + companion object { private val SPLITTER = Pattern.compile(",\\s*") - fun parse(raw: String) = Whitelist().also { + fun parse(raw: String) = this().also { for (s in raw.split(SPLITTER)) { it.add(s) }