class OfflineBatteryPostProcessor implements AlertPostProcessor {

   @Override
   public void postProcess(SubsystemContext<PlaceMonitorSubsystemModel> context, AlertScratchPad originalAlerts, AlertScratchPad scratch) {
      originalAlerts.alerts(lowBatteryFilter).forEach(alert -> {
         String offlineKey = AlertKeys.key(SmartHomeAlert.ALERTTYPE_DEV_ERR_OFFLINE, alert.getSubjectaddr());

         // device is most likely offline due to a low battery so remove the general offline and low battery then
         // replace with the offline due to low battery err
         if(originalAlerts.hasAlert(offlineKey)) {
            scratch.removeAlert(offlineKey);
            scratch.removeAlert(alert.getAlertkey());
            scratch.putAlert(createOfflineBattery(alert)); // note, this alert is cleared by a DeviceOnlineEvent in the DeviceOfflineGenerator
         }
      });
   }

}