0
我有一類WorldGodsVoice
對象的值未設置
class WorldGodsVoice extends Thread implements IThreadable {
def innerId
boolean isSequenced
long wait
def messages = []
volatile isEternal = true
def seq_id = 0
....
}
我WorldGodsVoice
與其他類
class GodsVoiceSubsystem extends Subsystem {
def component = new WorldGodsVoice()
def activate() {
component.start()
}
def disable() {
component.stopThread()
}
String toString() {
component
}
}
包裝和保持這種封裝類的一些全局對象內部LifeFramework
@Component
class LifeFramework extends ComplexFramework {
static final service_config = "config/service-config.xml";
def file
{
file = Gdx.files.internal(service_config).file
loaders << [ "godsVoice" : new WorldGodsVoiceConfigLoader() ]
subsystems << [ "godsVoice" : new GodsVoiceSubsystem() ]
}
def initSubsystems() {
loaders.each { k, v -> v.load(file, subsystems[k]) }
subsystems.each { k, v ->
v.activate()
}
}
def destroySubsystems() {
subsystems.each { k, v ->
v.disable()
}
}
def accessSubsystem(id) {
subsystems[id]
}
}
ComplexFramework
is ju st抽象類與方法和loaders, subsystems
字段。
配置爲WorldGodsVoice
我一直在xml
文件
<?xml version="1.0"?>
<services>
<service id="godsVoice">
<innerId>GOD_S_VOICE</innerId>
<wait>1000</wait>
<messages sequenced="false">
The world is living...Without a hero!
The world is filled with life!
The world is eternal!
</messages>
</service>
</services>
我處理xml
這樣
abstract class XmlConfigSubsystemLoader {
def load(file, subsystem) {
def xml = new ServiceConfigLoader().load(file) // new XmlSlurper().parse(file)
processXml(xml.'*'.find { node -> [email protected] == subsystemId() }, subsystem)
}
abstract subsystemId()
abstract processXml(xml, subsystem)
}
和抽象方法看起來像這樣
class WorldGodsVoiceConfigLoader extends XmlConfigSubsystemLoader {
def subsystemId() { "godsVoice" }
def processXml(xml, subsystem) {
subsystem.component.innerId = xml.innerId.text()
subsystem.component.wait = xml.wait.text() as Long
subsystem.component.messages = xml.messages.text().trim().split("!").collect { it.trim() } as String[]
subsystem.component.isSequenced = [email protected]
println "${ [email protected] }" // false
println "${ subsystem.component.isSequenced }" // true
}
}
的問題是,儘管擁有所有其他fie lds設置 - 它不想爲對象設置isSequenced
字段。它始終返回isSequenced
默認值或設置在對象內(如boolean isSequenced = true
)的值。
什麼問題?
Hm..I不知道什麼阻止其至少檢查可能的布爾值。 – lapots
不知道,它更符合列表,地圖,整數等這種方式。現在改變它會破壞數百萬應用程序,所以我想這就是它的保留方式 –