Perform some code refactor
This commit is contained in:
@@ -10,10 +10,10 @@ abstract class Function(val name: String) {
|
||||
private var definitions: List<FunctionDefinition> = mutableListOf()
|
||||
private var _module: Module? = null
|
||||
var module: Module
|
||||
get() = _module ?: throw RuntimeException("Method has not set module yet")
|
||||
get() = _module ?: throw RuntimeException("Function has not set module yet")
|
||||
set(value) {
|
||||
if (_module != null) {
|
||||
throw RuntimeException("Module of method is already set to ${module.canonicalName}")
|
||||
throw RuntimeException("Function of method is already set to ${module.canonicalName}")
|
||||
}
|
||||
_module = value
|
||||
}
|
||||
|
||||
@@ -2,10 +2,12 @@ package io.smnp.ext
|
||||
|
||||
import io.smnp.callable.function.Function
|
||||
import io.smnp.callable.method.Method
|
||||
import io.smnp.type.module.Module
|
||||
import org.pf4j.ExtensionPoint
|
||||
|
||||
interface ModuleDefinition : ExtensionPoint {
|
||||
fun modulePath(): String
|
||||
fun functions(): List<Function>
|
||||
fun methods(): List<Method>
|
||||
abstract class ModuleDefinition(val path: String) : ExtensionPoint {
|
||||
open fun functions(): List<Function> = emptyList()
|
||||
open fun methods(): List<Method> = emptyList()
|
||||
|
||||
fun module(): Module = Module.create(path, functions(), methods())
|
||||
}
|
||||
Reference in New Issue
Block a user