[java/cs] Use enumIndex for enum matches. Closes #3250