result = props.get(propertyName);
if (result == null || Deferred.INSTANCE.equals(result)) {
try {
Map<String, Object> delegate = getDelegate();
if (delegate instanceof Document) {
Document doc = (Document) delegate;
result = doc.getItemValue(propertyName, T);
} else {
result = T.cast(delegate.get(propertyName));
}
if (result == null) {
props.put(propertyName, Null.INSTANCE);
} else if (result instanceof Serializable) {
props.put(propertyName, result);
} else {
log_.log(Level.FINE, "Got a value from the document but it's not Serializable. It's a " + result.getClass().getName());
props.put(propertyName, result);
}
} catch (Exception e) {
log_.log(Level.WARNING, "Exception occured attempting to get value from document for " + propertyName
+ " so we cannot return a value", e);
}
} else if (result == Null.INSTANCE) {
} else {
if (result != null && !T.isAssignableFrom(result.getClass())) {
try {
Map<String, Object> delegate = getDelegate();
if (delegate instanceof Document) {
Document doc = (Document) delegate;
result = doc.getItemValue(propertyName, T);
} else {
Object chk = delegate.get(propertyName);
if (chk != null) {
result = T.cast(delegate.get(propertyName));
}