Here you can find the source of setFields(Field field, Object value, Object config)
public static boolean setFields(Field field, Object value, Object config)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { public static boolean setFields(Field field, Object value, Object config) { boolean flag = true; Class<?> clazz = field.getType(); try {//from w ww .j ava 2s .com switch (clazz.getName()) { case "boolean": field.set(config, Boolean.valueOf((String) value)); break; case "int": field.set(config, Integer.valueOf((String) value)); break; case "long": field.set(config, Long.valueOf((String) value)); break; case "java.lang.String": field.set(config, (String) value); break; default: flag = false; break; } } catch (IllegalArgumentException | IllegalAccessException e) { flag = false; } return flag; } }