List<String> keyNameElements,
int elementIndex,
List<KeyInfo> keyInfoList,
KeyInfo keyInfo) {
String keyElement = keyNameElements.get(elementIndex);
Property property = schema.getProperties().get(keyElement);
if (property == null) {
return null;
}
keyInfo.addElementToPath(keyElement);
Object value = null;
try {
value = property.getGetterMethod().invoke(record);
} catch (Exception e) {
if (debug) {
System.out.println("key element is " + keyElement);
e.printStackTrace();
}
}
if (value == null) {
return null; // return a null KeyInfo list if we hit a null value
}
if (property.isList()) {
List list = (List) value;
// TODO: handle case where key does not include property of
// component type
Schema componentSchema = property.getComponentProperty()
.getSchema();
int listLength = list.size();
for (int i = 0; i < listLength; i++) {
Object listEntry = list.get(i);
KeyInfo keyInfoForListEntry = keyInfo.copy();
keyInfoForListEntry.addElementToPath(i);
Object partialList = getKeyValues(listEntry,
componentSchema,
keyNameElements,
elementIndex + 1,
keyInfoList,
keyInfoForListEntry);
if (partialList == null) {
return null;
}
}
} else if (property.getSchema() != null) {
return getKeyValues(value,
property.getSchema(),
keyNameElements,
elementIndex + 1,
keyInfoList,
keyInfo);
} else {