package com.xxx.common.util;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Field; /**
* @version 1.0.0
* @date 2021-01-15 17:53
*/
@Slf4j
public class TrimUtil {
public static void trimStringFieldInObject(Class<?> clazz, Object t) {
Field[] fields = clazz.getClass().getFields();
for (Field field : fields) {
try {
if (field.get(t) instanceof String) {
Object o = field.get(t);
String s = (String) o;
field.set(t, StringUtils.trimToEmpty(s));
}
} catch (IllegalAccessException e) {
log.warn("converting field {} error", field.getName());
}
}
}
}

https://stackoverflow.com/questions/9189520/trim-all-strings-elements-in-a-complex-object

trim-all-strings-elements-in-a-complex-object的更多相关文章

  1. Effective Java 06 Eliminate obsolete object references

    NOTE Nulling out object references should be the exception rather than the norm. Another common sour ...

  2. Post Complex JavaScript Objects to ASP.NET MVC Controllers

    http://www.nickriggs.com/posts/post-complex-javascript-objects-to-asp-net-mvc-controllers/     Post ...

  3. Go开发之路 -- strings以及strconv的使用

    strings的使用 HasPrefix 语法: strings.HasPrefix(s, prefix string) bool // 判断字符串s是否以prefix开头 // 判断一个url是否以 ...

  4. TypeError: 'range' object does not support item assignment

    TypeError: 'range' object does not support item assignment I was looking at some python 2.x code and ...

  5. python __builtins__ complex类 (13)

    13.'complex', 函数用于创建一个值为 real + imag * j 的复数或者转化一个字符串或数为复数.如果第一个参数为字符串,则不需要指定第二个参数. class complex(ob ...

  6. Python3基础 complex 声明复数

             Python : 3.7.3          OS : Ubuntu 18.04.2 LTS         IDE : pycharm-community-2019.1.3    ...

  7. jquery-1.11.1.js

       每次想要使用这个js时,总是要到官网上下载,太麻烦,现在把它收录了 jquery-1.11.1.js /*! * jQuery JavaScript Library v1.11.1 * http ...

  8. modern-cpp-features

    C++17/14/11 Overview Many of these descriptions and examples come from various resources (see Acknow ...

  9. 关于C#你应该知道的2000件事

    原文 关于C#你应该知道的2000件事 下面列出了迄今为止你应该了解的关于C#博客的2000件事的所有帖子. 帖子总数= 1,219 大会 #11 -检查IL使用程序Ildasm.exe d #179 ...

  10. Unity 最佳实践

    转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...

随机推荐

  1. Kali Linux 更新 一条命令搞定

    Kali Linux 更新 一条命令搞定 sudo apt-get update && sudo apt-get upgrade && sudo apt-get dis ...

  2. 云原生爱好者周刊:Cilium 放大招,发布服务网格 Beta 版

    云原生一周动态要闻: Cilium 推出服务网格测试计划 Knative 已申请成为 CNCF 的孵化项目 Kubernetes v1.23 即将发布 Lens 5.3 发布 开源项目推荐 文章推荐 ...

  3. Machine Learning Week_1 Introduction 5-8

    目录 1.5 Vedio: Supervised Learning unfamiliar words 1.6 Reading: Supervised Learning unfamiliar words ...

  4. IntelliJ IDEA 2024.1 安装激活 (亲测有效!)

    第一步:下载 IDEA 安装包 访问 IDEA 官网,下载 IDEA 2024.1.4 版本的安装包,下载链接如下 : idea官方链接 也可以在这里点击下载idea下载idea 第二步: 安装 ID ...

  5. selenium3环境搭建,Firefox与对应的geckodriver, chrome与对应的Chromedriver

    Firefox与对应的geckodriver 火狐下载:http://ftp.mozilla.org/pub/firefox/releases/ geckodriver下载:https://githu ...

  6. 2021“MINIEYE杯”(1)

    Start Time : 2021-07-20 12:10:00 End Time : 2021-07-20 17:10:00 1001-Mod, Or and Everything 真正的签到题 题 ...

  7. docker连不上私有仓库Harbor

    解决办法: # 配置多个host(配置本地域名映射) [root@vm10-11-0-38 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.local ...

  8. 干货分享:Air700ECQ的硬件设计,第一部分

    ​ 一.绪论 Air700ECQ是一款基于移芯EC716E平台设计的LTE Cat 1无线通信模组.支持移动双模FDD-LTE/TDD-LTE的4G远距离无线传输技术.以极小封装,极高性价比,满足Io ...

  9. 轻松上云怎么操作?IoT_CLOUD之中移OneNET

    ​  最近来了很多新朋友,也经常被问:可以多讲些云平台的操作吗?当然可以!文末留言你想要了解的云平台,优先安排~ 接下来,本文将以Air780E+LuatOS作为示例,教你使用合宙IoT_CLOUD连 ...

  10. MaskLLM:英伟达出品,用于大模型的可学习`N:M`稀疏化 | NeurIPS'24

    来源:晓飞的算法工程笔记 公众号,转载请注明出处 论文: MaskLLM: Learnable Semi-Structured Sparsity for Large Language Models 论 ...