if (o == null) {
outputField = false;
Logger.trace(" Excluding due to NULL in ifExists check - field: " + field.getIfExists());
} else {
// Now, check if this is an empty payload, which is equivalent to not existing..
Field defn = p.getFieldDefinitions().get(fieldName);
FieldHandler handler = defn.getHandler();
if (handler.isPayload()) {
boolean isBlank = true;
if (defn.getMaxOccurs()>1) {
for (Object fieldListItem : (ArrayList)o) {
if (!handler.isItemBlank(defn, fieldListItem, true)) {
isBlank = false;
}
}
} else {
isBlank = handler.isItemBlank(defn, o, false);
}
if (isBlank) {
outputField = false;
Logger.trace(" Excluding due to ifExists check - this is an empty child payload - field: " + field.getIfExists());
}
}
Logger.trace(" NOT EXCLUDING - ifExists check - field: " + field.getIfExists());
}
}
// See of there is an ifNotExists condition attached
fieldName = field.getIfNotExists();
if (fieldName != null) {
// See whether the required field does exist - if it does, prevent this field being added
Object o = p.getValue(fieldName);
if (o != null) {
// Now, check if this is an empty payload, which is equivalent to not existing..
Field defn = p.getFieldDefinitions().get(fieldName);
FieldHandler handler = defn.getHandler();
if (handler.isPayload()) {
boolean isBlank = handler.isItemBlank(defn, o, false);
if (!isBlank) {
outputField = false;
Logger.trace(" Excluding due to ifNotExists check - this is a non-empty child payload - field: " + field.getIfExists());