in ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/AbstractStructuredInvocationHandler.java [279:393]
protected Object getPropertyValue(final String name, final Type type) {
try {
Object res;
final Class<?> ref = ClassUtils.getTypeClass(type);
if (ref == EdmStreamValue.class) {
if (streamedPropertyCache.containsKey(name)) {
res = streamedPropertyCache.get(name);
} else if (streamedPropertyChanges.containsKey(name)) {
res = streamedPropertyChanges.get(name);
} else {
res = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {EdmStreamValue.class}, new EdmStreamValueHandler(
baseURI == null
? null
: getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name).build(),
service));
streamedPropertyCache.put(name, EdmStreamValue.class.cast(res));
}
return res;
} else {
if (propertyChanges.containsKey(name)) {
res = propertyChanges.get(name);
} else if (propertyCache.containsKey(name)) {
res = propertyCache.get(name);
} else {
final ClientProperty property = getInternalProperty(name);
if (ref != null && ClassUtils.getTypeClass(type).isAnnotationPresent(ComplexType.class)) {
res = getComplex(
name,
property == null || property.hasNullValue() ? null : property.getValue(),
ref,
getEntityHandler(),
baseURI,
false);
} else if (ref != null && ComplexCollection.class.isAssignableFrom(ref)) {
final ComplexCollectionInvocationHandler<?> collectionHandler;
final Class<?> itemRef = ClassUtils.extractTypeArg(ref, ComplexCollection.class);
if (property == null || property.hasNullValue()) {
collectionHandler = new ComplexCollectionInvocationHandler(
itemRef,
service,
baseURI == null
? null : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name));
} else {
List items = new ArrayList();
for (ClientValue item : property.getValue().asCollection()) {
items.add(getComplex(
name,
item,
itemRef,
getEntityHandler(),
null,
true));
}
collectionHandler = new ComplexCollectionInvocationHandler(
service,
items,
itemRef,
baseURI == null
? null : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name));
}
res = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {ref}, collectionHandler);
} else if (ref != null && PrimitiveCollection.class.isAssignableFrom(ref)) {
PrimitiveCollectionInvocationHandler collectionHandler;
if (property == null || property.hasNullValue()) {
collectionHandler = new PrimitiveCollectionInvocationHandler(
service,
null,
baseURI == null
? null : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name));
} else {
List items = new ArrayList();
for (ClientValue item : property.getValue().asCollection()) {
items.add(item.asPrimitive().toValue());
}
collectionHandler = new PrimitiveCollectionInvocationHandler(
service,
items,
null,
baseURI == null
? null : getClient().newURIBuilder(baseURI.toASCIIString()).appendPropertySegment(name));
}
res = Proxy.newProxyInstance(
Thread.currentThread().getContextClassLoader(),
new Class<?>[] {PrimitiveCollection.class}, collectionHandler);
} else {
res = property == null || property.hasNullValue()
? null
: CoreUtils.getObjectFromODataValue(property.getValue(), type, service);
}
}
if (res != null) {
propertyCache.put(name, res);
}
return res;
}
} catch (Exception e) {
throw new IllegalArgumentException("Error getting value for property '" + name + "'", e);
}
}