class ObscureIfHubOfflinePostProcessor implements AlertPostProcessor {

   @Override
   public void postProcess(SubsystemContext<PlaceMonitorSubsystemModel> context, AlertScratchPad originalAlerts, AlertScratchPad scratch) {
      if(!originalAlerts.hasAlert(AlertKeys.key(SmartHomeAlert.ALERTTYPE_PLACE_HUB_OFFLINE, context.getPlaceId()))) {
         // no hub offline alert so there is no need to obscure 4g or device offline errors for devices behind the hub
         return;
      }

      originalAlerts.alerts(obscureFilter).forEach(alert -> {
         boolean remove = true;
         if(SmartHomeAlert.ALERTTYPE_DEV_ERR_OFFLINE.equals(alert.getAlerttype())) {
            // only remove device offline errors for those devices that require a hub
            Model dev = context.models().getModelByAddress(Address.fromString(alert.getSubjectaddr()));
            if(dev != null && !requiresHub(dev)) {
               remove = false;
            }
         }
         if(remove) {
            scratch.removeAlert(alert.getAlertkey());
         }
      });
   }

}