Optimize checkListeners()

This changes the use of StringBuffer to StringBuilder. Also use
Preconditions.checkState().

Change-Id: I378cc84d7b70010cd9559ad6ef3a278ce5f07c90
Signed-off-by: Robert Varga <rovarga@cisco.com>
Signed-off-by: Michal Polkorab <michal.polkorab@pantheon.sk>