mirror of
https://github.com/revanced/revanced-patcher.git
synced 2025-05-01 13:44:25 +02:00
refactor: add FileOption alias for PathOption
This commit is contained in:
parent
392164862c
commit
bb97af4d86
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
package app.revanced.patcher.patch
|
package app.revanced.patcher.patch
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
@ -195,14 +196,31 @@ sealed class PatchOption<T>(
|
|||||||
* A [PatchOption] representing a [Path].
|
* A [PatchOption] representing a [Path].
|
||||||
* @see PatchOption
|
* @see PatchOption
|
||||||
*/
|
*/
|
||||||
class PathOption<T: Path>(
|
sealed class PathOption(
|
||||||
key: String,
|
key: String,
|
||||||
default: T?,
|
default: Path?,
|
||||||
title: String,
|
title: String,
|
||||||
description: String,
|
description: String,
|
||||||
required: Boolean = false,
|
required: Boolean = false,
|
||||||
validator: (T?) -> Boolean = { true }
|
validator: (Path?) -> Boolean = { true }
|
||||||
) : PatchOption<T>(
|
) : PatchOption<Path>(
|
||||||
key, default, title, description, required, validator
|
key, default, title, description, required, validator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A [PathOption] of type [File].
|
||||||
|
* @see PathOption
|
||||||
|
*/
|
||||||
|
class FileOption(
|
||||||
|
key: String,
|
||||||
|
default: File?,
|
||||||
|
title: String,
|
||||||
|
description: String,
|
||||||
|
required: Boolean = false,
|
||||||
|
validator: (File?) -> Boolean = { true }
|
||||||
|
) : PathOption(
|
||||||
|
key, default?.toPath(), title, description, required, {
|
||||||
|
validator(it?.toFile())
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user