Replace ternary operation by separate method.

Fix warning from CheckStyle.

Correction for 681913b8b5228b6c8662206692277ae72726187f commit.

No functional changes.