2525
2626import microsoft .exchange .webservices .data .core .EwsServiceXmlReader ;
2727import microsoft .exchange .webservices .data .core .EwsServiceXmlWriter ;
28+ import microsoft .exchange .webservices .data .core .ExchangeService ;
2829import microsoft .exchange .webservices .data .core .PropertyBag ;
29- import microsoft .exchange .webservices .data .core .service .ServiceObject ;
3030import microsoft .exchange .webservices .data .core .enumeration .misc .ExchangeVersion ;
31- import microsoft .exchange .webservices .data .core .enumeration .property .PropertyDefinitionFlags ;
3231import microsoft .exchange .webservices .data .core .enumeration .misc .XmlNamespace ;
32+ import microsoft .exchange .webservices .data .core .enumeration .property .PropertyDefinitionFlags ;
33+ import microsoft .exchange .webservices .data .core .service .ServiceObject ;
3334import microsoft .exchange .webservices .data .misc .OutParam ;
3435import microsoft .exchange .webservices .data .property .complex .ComplexProperty ;
3536
@@ -92,19 +93,18 @@ protected ComplexPropertyDefinitionBase(String xmlElementName, String uri,
9293 * @param propertyBag The property bag.
9394 * @throws Exception the exception
9495 */
95- protected void internalLoadFromXml (EwsServiceXmlReader reader ,
96- PropertyBag propertyBag ) throws Exception {
97- OutParam <Object > complexProperty = new OutParam <Object >();
96+ protected void internalLoadFromXml (
97+ final EwsServiceXmlReader reader , final PropertyBag propertyBag
98+ ) throws Exception {
99+ final OutParam <ComplexProperty > complexProperty = new OutParam <ComplexProperty >();
100+ final boolean justCreated = getPropertyInstance (propertyBag , complexProperty );
98101
99- boolean justCreated = getPropertyInstance (propertyBag , complexProperty );
100102 if (!justCreated && this .hasFlag (PropertyDefinitionFlags .UpdateCollectionItems ,
101103 propertyBag .getOwner ().getService ().getRequestedServerVersion ())) {
102- Object c = complexProperty .getParam ();
103- if (c instanceof ComplexProperty ) {
104- ((ComplexProperty ) c ).updateFromXml (reader , reader .getLocalName ());
105- }
104+ final ComplexProperty c = complexProperty .getParam ();
105+ c .updateFromXml (reader , reader .getLocalName ());
106106 } else {
107- ComplexProperty c = ( ComplexProperty ) complexProperty .getParam ();
107+ final ComplexProperty c = complexProperty .getParam ();
108108 c .loadFromXml (reader , reader .getLocalName ());
109109 }
110110
@@ -121,17 +121,18 @@ protected void internalLoadFromXml(EwsServiceXmlReader reader,
121121 * @param complexProperty The property instance.
122122 * @return True if the instance is newly created.
123123 */
124- private boolean getPropertyInstance (PropertyBag propertyBag , OutParam <Object > complexProperty ) {
125- boolean retValue = false ;
126- if (!propertyBag .tryGetValue (this , complexProperty ) || !this
127- .hasFlag (PropertyDefinitionFlags .ReuseInstance ,
128- propertyBag .getOwner ().getService ().getRequestedServerVersion ())) {
129- complexProperty .setParam (this .createPropertyInstance (propertyBag
130- .getOwner ()));
131- retValue = true ;
124+ private boolean getPropertyInstance (
125+ final PropertyBag propertyBag , final OutParam <ComplexProperty > complexProperty
126+ ) {
127+ final ServiceObject owner = propertyBag .getOwner ();
128+ final ExchangeService service = owner .getService ();
129+
130+ if (!propertyBag .tryGetValue (this , complexProperty )
131+ || !hasFlag (PropertyDefinitionFlags .ReuseInstance , service .getRequestedServerVersion ())) {
132+ complexProperty .setParam (createPropertyInstance (owner ));
133+ return true ;
132134 }
133- return retValue ;
134-
135+ return false ;
135136 }
136137
137138 /**
0 commit comments