protected RedirectCondition readElement(StaxNavigator<Element> navigator) {
if (navigator.getName() != Element.CONDITION) {
throw expectedElement(navigator, Element.CONDITION);
}
RedirectCondition condition = new RedirectCondition();
Element element = navigator.child();
if (element != Element.NAME) {
throw expectedElement(navigator, Element.NAME);
}
condition.setName(getRequiredContent(navigator, true));
boolean userAgent = false;
boolean deviceProperties = false;
while (navigator.sibling() != null) {
switch (navigator.getName()) {
case USER_AGENT:
if (userAgent || deviceProperties) {
throw unexpectedElement(navigator);
}
userAgent = true;
condition.setUserAgentConditions(userAgentXmlHandler.read(navigator.fork()));
break;
case DEVICE_PROPERTIES:
if (deviceProperties) {
throw unexpectedElement(navigator);
}
deviceProperties = true;
condition.setDeviceProperties((ArrayList<DevicePropertyCondition>) devicePropertyXmlHandler.read(navigator.fork()));
break;
case UNKNOWN:
throw unknownElement(navigator);
default:
throw unexpectedElement(navigator);