mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2024-11-10 09:08:04 +01:00
refactor: add FileOption alias for PathOption
This commit is contained in:
parent
392164862c
commit
bb97af4d86
1 changed files with 22 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
|||
|
||||
package app.revanced.patcher.patch
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Path
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
|
@ -195,14 +196,31 @@ sealed class PatchOption<T>(
|
|||
* A [PatchOption] representing a [Path].
|
||||
* @see PatchOption
|
||||
*/
|
||||
class PathOption<T: Path>(
|
||||
sealed class PathOption(
|
||||
key: String,
|
||||
default: T?,
|
||||
default: Path?,
|
||||
title: String,
|
||||
description: String,
|
||||
required: Boolean = false,
|
||||
validator: (T?) -> Boolean = { true }
|
||||
) : PatchOption<T>(
|
||||
validator: (Path?) -> Boolean = { true }
|
||||
) : PatchOption<Path>(
|
||||
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…
Reference in a new issue