Skip to content

Commit 67220a7

Browse files
committed
fix casts - learn java
1 parent 55791ce commit 67220a7

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/main/java/microsoft/exchange/webservices/data/core/service/ServiceObject.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,17 @@ public void load() throws Exception {
391391
* @return The value of specified property in this instance.
392392
* @throws Exception the exception
393393
*/
394-
public Object getObjectFromPropertyDefinition(
395-
PropertyDefinitionBase propertyDefinition) throws Exception {
396-
PropertyDefinition propDef = (PropertyDefinition) propertyDefinition;
397-
398-
if (propDef != null) {
399-
return this.getPropertyBag().getObjectFromPropertyDefinition(propDef);
400-
} else {
394+
public Object getObjectFromPropertyDefinition(PropertyDefinitionBase propertyDefinition) throws Exception {
395+
396+
if(propertyDefinition instanceof PropertyDefinition) {
397+
return this.getPropertyBag().getObjectFromPropertyDefinition((PropertyDefinition) propertyDefinition);
398+
} else if(propertyDefinition instanceof ExtendedPropertyDefinition){
399+
OutParam<Object> propertyValue = new OutParam<Object>();
400+
if(this.tryGetExtendedProperty(Object.class, (ExtendedPropertyDefinition)propertyDefinition, propertyValue)){
401+
return propertyValue.getParam();
402+
}
403+
return null;
404+
} else {
401405
// E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported.
402406
throw new UnsupportedOperationException(String.format(
403407
"This operation isn't supported for property definition type %s.",
@@ -452,9 +456,10 @@ public boolean tryGetProperty(PropertyDefinitionBase propertyDefinition, OutPara
452456
public <T> boolean tryGetProperty(Class<T> cls, PropertyDefinitionBase propertyDefinition,
453457
OutParam<T> propertyValue) throws Exception {
454458

455-
PropertyDefinition propDef = (PropertyDefinition) propertyDefinition;
456-
if (propDef != null) {
457-
return this.getPropertyBag().tryGetPropertyType(cls, propDef, propertyValue);
459+
if(propertyDefinition instanceof PropertyDefinition) {
460+
return this.getPropertyBag().tryGetPropertyType(cls, (PropertyDefinition) propertyDefinition, propertyValue);
461+
} else if(propertyDefinition instanceof ExtendedPropertyDefinition){
462+
return this.tryGetExtendedProperty(cls, (ExtendedPropertyDefinition) propertyDefinition, propertyValue);
458463
} else {
459464
// E14:226103 -- Other subclasses of PropertyDefinitionBase are not supported.
460465
throw new UnsupportedOperationException(String.format(

0 commit comments

Comments
 (0)