@Test public void testSwapper() { BeanA beanA = new BeanA(); BeanUtils.swapper(beanA, "aA", 1, ""); BeanUtils.swapper(beanA, "bB", 2L, "_"); BeanUtils.swapper(beanA, "c_C", 3d, "_"); BeanUtils.swapper(beanA, "dD", beanA, "_"); assertEquals("{\"aA\":1,\"bB\":2,\"cC\":3.0,\"d_D\":{\"$ref\":\"@\"}}", beanA.toString()); }
public static void swapper(Object o, String key, Object value, String... ignores) { if (o == null || StrUtils.isEmpty(key)) return; Class<?> clazz = o.getClass(); if (clazz == null) return; String className = clazz.getName(); if (StrUtils.isEmpty(className)) return; Vector<Field> fields = getFields(clazz, className); if (fields == null || fields.size() == 0) return; for (Field field : fields) { if (field == null) continue; if (valueField(o, key, value, field, ignores)) return; } LOGGER.debug("[Warn] Cannot be swapped! object: {}, key: {}, value: {}, ignores: {}", o, key, value, JSON.toJSONString(ignores)); }
BeanUtils { public static void swapper(Object o, String key, Object value, String... ignores) { if (o == null || StrUtils.isEmpty(key)) return; Class<?> clazz = o.getClass(); if (clazz == null) return; String className = clazz.getName(); if (StrUtils.isEmpty(className)) return; Vector<Field> fields = getFields(clazz, className); if (fields == null || fields.size() == 0) return; for (Field field : fields) { if (field == null) continue; if (valueField(o, key, value, field, ignores)) return; } LOGGER.debug("[Warn] Cannot be swapped! object: {}, key: {}, value: {}, ignores: {}", o, key, value, JSON.toJSONString(ignores)); } }
BeanUtils { public static void swapper(Object o, String key, Object value, String... ignores) { if (o == null || StrUtils.isEmpty(key)) return; Class<?> clazz = o.getClass(); if (clazz == null) return; String className = clazz.getName(); if (StrUtils.isEmpty(className)) return; Vector<Field> fields = getFields(clazz, className); if (fields == null || fields.size() == 0) return; for (Field field : fields) { if (field == null) continue; if (valueField(o, key, value, field, ignores)) return; } LOGGER.debug("[Warn] Cannot be swapped! object: {}, key: {}, value: {}, ignores: {}", o, key, value, JSON.toJSONString(ignores)); } private  BeanUtils(); }
BeanUtils { public static void swapper(Object o, String key, Object value, String... ignores) { if (o == null || StrUtils.isEmpty(key)) return; Class<?> clazz = o.getClass(); if (clazz == null) return; String className = clazz.getName(); if (StrUtils.isEmpty(className)) return; Vector<Field> fields = getFields(clazz, className); if (fields == null || fields.size() == 0) return; for (Field field : fields) { if (field == null) continue; if (valueField(o, key, value, field, ignores)) return; } LOGGER.debug("[Warn] Cannot be swapped! object: {}, key: {}, value: {}, ignores: {}", o, key, value, JSON.toJSONString(ignores)); } private  BeanUtils(); static void swapper(Object o, String key, Object value, String... ignores); static LinkedList<String> columns2Row(List<T> objList, String[] fields,
                                                     boolean isLongTail, boolean forDruid, Object... ignores); static LinkedList<String> columns2Row(List<T> objList, String[] fields,
                                                     Class parentClass, boolean isLongTail,
                                                     boolean forDruid, Object... ignores); static LinkedList<String> column2Row(T obj, String[] fields, boolean isLongTail,
                                                    boolean forDruid, Object... ignores); static LinkedList<String> column2Row(T obj, String[] fields, Class parentClass,
                                                    boolean isLongTail, boolean forDruid, Object... ignores); static LinkedList<String> columns2Row(List<T> objList, Set<Field> head,
                                                     Set<Field> tail, boolean forDruid); static LinkedList<String> column2Row(T obj, Set<Field> head, Set<Field> tail, boolean forDruid); static void dealWithTail(T obj, Set<Field> tail, LinkedList<String> rows, JSONObject jsonObject); static void dealWithTail4Druid(T obj, Set<Field> tail, LinkedList<String> rows, JSONObject jsonObject); static Vector<Field> getFields(Class<?> clazz, String className); static Vector<Field> getAllFields(Class clazz); }
BeanUtils { public static void swapper(Object o, String key, Object value, String... ignores) { if (o == null || StrUtils.isEmpty(key)) return; Class<?> clazz = o.getClass(); if (clazz == null) return; String className = clazz.getName(); if (StrUtils.isEmpty(className)) return; Vector<Field> fields = getFields(clazz, className); if (fields == null || fields.size() == 0) return; for (Field field : fields) { if (field == null) continue; if (valueField(o, key, value, field, ignores)) return; } LOGGER.debug("[Warn] Cannot be swapped! object: {}, key: {}, value: {}, ignores: {}", o, key, value, JSON.toJSONString(ignores)); } private  BeanUtils(); static void swapper(Object o, String key, Object value, String... ignores); static LinkedList<String> columns2Row(List<T> objList, String[] fields,
                                                     boolean isLongTail, boolean forDruid, Object... ignores); static LinkedList<String> columns2Row(List<T> objList, String[] fields,
                                                     Class parentClass, boolean isLongTail,
                                                     boolean forDruid, Object... ignores); static LinkedList<String> column2Row(T obj, String[] fields, boolean isLongTail,
                                                    boolean forDruid, Object... ignores); static LinkedList<String> column2Row(T obj, String[] fields, Class parentClass,
                                                    boolean isLongTail, boolean forDruid, Object... ignores); static LinkedList<String> columns2Row(List<T> objList, Set<Field> head,
                                                     Set<Field> tail, boolean forDruid); static LinkedList<String> column2Row(T obj, Set<Field> head, Set<Field> tail, boolean forDruid); static void dealWithTail(T obj, Set<Field> tail, LinkedList<String> rows, JSONObject jsonObject); static void dealWithTail4Druid(T obj, Set<Field> tail, LinkedList<String> rows, JSONObject jsonObject); static Vector<Field> getFields(Class<?> clazz, String className); static Vector<Field> getAllFields(Class clazz);  }