/**
  * Validates this instance for AddDelegate.
  *
  * @throws ServiceValidationException
  */
 protected void validateAddDelegate() throws ServiceValidationException {
   for (DelegateFolderPermission delegateFolderPermission :
       this.delegateFolderPermissions.values()) {
     if (delegateFolderPermission.getPermissionLevel() == DelegateFolderPermissionLevel.Custom) {
       throw new ServiceValidationException(
           Strings.CannotSetDelegateFolderPermissionLevelToCustom);
     }
   }
 }
  /**
   * Tries to read element from XML.
   *
   * @param reader the reader
   * @return Returns true if element was read.
   * @throws Exception the exception
   */
  protected boolean tryReadElementFromXml(EwsServiceXmlReader reader) throws Exception {
    DelegateFolderPermission delegateFolderPermission = null;

    if (this.delegateFolderPermissions.containsKey(reader.getLocalName())) {
      delegateFolderPermission = this.delegateFolderPermissions.get(reader.getLocalName());
      delegateFolderPermission.initialize(
          reader.readElementValue(DelegateFolderPermissionLevel.class));
    }

    return delegateFolderPermission != null;
  }
 /** Reset. */
 protected void reset() {
   for (DelegateFolderPermission delegateFolderPermission :
       this.delegateFolderPermissions.values()) {
     delegateFolderPermission.reset();
   }
 }