Change order of conditions to simplify these.
Check for:  if (watermark == null) ... else if (watermark instanceof Serializable) ... else ...