/**
   * Returns true if the specified notification is newer than the current one.
   *
   * @param response the notification
   * @return true if the notification is new
   */
  public synchronized boolean isNew(Response response) {

    if (!response.getOptions().hasObserve()) {
      // this is a final response, e.g., error or proactive cancellation
      return true;
    }

    // Multiple responses with different notification numbers might
    // arrive and be processed by different threads. We have to
    // ensure that only the most fresh one is being delivered.
    // We use the notation from the observe draft-08.
    long T1 = getTimestamp();
    long T2 = System.currentTimeMillis();
    int V1 = getCurrent();
    int V2 = response.getOptions().getObserve();
    int notifMaxAge =
        NetworkConfig.getStandard().getInt(NetworkConfigDefaults.NOTIFICATION_MAX_AGE);
    if (V1 < V2 && V2 - V1 < 1 << 23 || V1 > V2 && V1 - V2 > 1 << 23 || T2 > T1 + notifMaxAge) {

      setTimestamp(T2);
      number.set(V2);
      return true;
    } else {
      return false;
    }
  }