26 lines
938 B
Java
26 lines
938 B
Java
package com.github.dtschust.zork.parser.strategies;
|
|
|
|
import com.github.dtschust.zork.ZorkCondition;
|
|
import com.github.dtschust.zork.ZorkConditionHas;
|
|
import com.github.dtschust.zork.ZorkConditionStatus;
|
|
import com.github.dtschust.zork.parser.Property;
|
|
import com.github.dtschust.zork.parser.PropertyParseStrategy;
|
|
|
|
public class ZorkConditionParseStrategy implements PropertyParseStrategy<ZorkCondition> {
|
|
@Override
|
|
public ZorkCondition parse(final Property source) {
|
|
if (source.hasSubProperty("has")) {
|
|
return new ZorkConditionHas(
|
|
source.subPropertyValue("has"),
|
|
source.subPropertyValue("object"),
|
|
source.subPropertyValue("owner")
|
|
);
|
|
} else {
|
|
return new ZorkConditionStatus(
|
|
source.subPropertyValue("status"),
|
|
source.subPropertyValue("object")
|
|
);
|
|
}
|
|
}
|
|
}
|