Используйте отражение вместо if-else

NoSuchKey

рекомендация

отblog.csdn.net/guoweiting/article/details/97500188