protected DevicePropertyCondition readElement(StaxNavigator<Element> navigator) {
if (navigator.getName() != Element.DEVICE_PROPERTY) {
throw unexpectedElement(navigator);
}
DevicePropertyCondition condition = new DevicePropertyCondition();
// property-name
String propertyName = getRequiredContent(child(navigator, Element.PROPERTY_NAME), true);
condition.setPropertyName(propertyName);
// greater-than
while (navigator.sibling() != null) {
switch (navigator.getName()) {
case GREATER_THAN:
if (condition.getGreaterThan() != null || condition.getLessThan() != null ||
condition.getMatches() != null || condition.getEquals() != null) {
throw unexpectedElement(navigator);
}
condition.setGreaterThan(parseRequiredContent(navigator, FLOAT_VALUE_TYPE));
break;
case LESS_THAN:
if (condition.getLessThan() != null || condition.getMatches() != null || condition.getEquals() != null) {
throw unexpectedElement(navigator);
}
condition.setLessThan(parseRequiredContent(navigator, FLOAT_VALUE_TYPE));
break;
case MATCHES:
if (condition.getMatches() != null || condition.getEquals() != null) {
throw unexpectedElement(navigator);
}
condition.setMatches(getRequiredContent(navigator, false));
break;
case EQUALS:
if (condition.getEquals() != null) {
throw unexpectedElement(navigator);
}
condition.setEquals(getRequiredContent(navigator, false));
break;
case UNKNOWN:
throw unknownElement(navigator);
default:
throw unexpectedElement(navigator);