当前位置: 首页 > news >正文

合肥的网站建设公司培训网站建设方案说明书

合肥的网站建设公司,培训网站建设方案说明书,做网站顾客提现金额后台,知名网站制作公司有哪些前言: BeanUtils默认的populate方法不会忽略空值和null值,在特定场景,我们需要原始的值避免被覆盖,所以这里提供一种自定义实现方式。 package com.hmwl.service.program;import lombok.extern.slf4j.Slf4j; import org.apache.commons.beanu…

前言: BeanUtils默认的populate方法不会忽略空值和null值,在特定场景,我们需要原始的值避免被覆盖,所以这里提供一种自定义实现方式。

package com.hmwl.service.program;import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.apache.commons.beanutils.ContextClassLoaderLocal;import java.lang.reflect.InvocationTargetException;
import java.util.Map;/*** @Author: martin* @Date: 2023/11/01 15:13 pm* @Description: apache common 原版populate不会过滤null值,不符合使用场景*/
@Slf4j
public class CustomBeanUtils extends BeanUtilsBean {private static final ContextClassLoaderLocal<CustomBeanUtils>BEANS_BY_CLASSLOADER = new ContextClassLoaderLocal<CustomBeanUtils>() {// Creates the default instance used when the context classloader is unavailable@Overrideprotected CustomBeanUtils initialValue() {return new CustomBeanUtils();}};public static CustomBeanUtils getInstance() {return BEANS_BY_CLASSLOADER.get();}public static void setInstance(final CustomBeanUtils newInstance) {BEANS_BY_CLASSLOADER.set(newInstance);}public static void populateIgnoreEmpty(final Object bean, final Map<String, ? extends Object> properties) {try {CustomBeanUtils.getInstance().populateIgnoreNull(bean, properties);} catch (IllegalAccessException e) {log.error(e.getMessage());} catch (InvocationTargetException e) {log.error(e.getMessage());}}private final void populateIgnoreNull(final Object bean, final Map<String, ? extends Object> properties)throws IllegalAccessException, InvocationTargetException {if ((bean == null) || (properties == null)) {return;}if (log.isDebugEnabled()) {log.debug("BeanUtils.populate(" + bean + ", " +properties + ")");}for (final Map.Entry<String, ? extends Object> entry : properties.entrySet()) {final String name = entry.getKey();// 增强下,因为可能多次调用,当value为null的时候不赋值if (name == null || entry.getValue() == null) {continue;}setProperty(bean, name, entry.getValue());}}
}

原版实现:

    public void populate(final Object bean, final Map<String, ? extends Object> properties)throws IllegalAccessException, InvocationTargetException {// Do nothing unless both arguments have been specifiedif ((bean == null) || (properties == null)) {return;}if (log.isDebugEnabled()) {log.debug("BeanUtils.populate(" + bean + ", " +properties + ")");}// Loop through the property name/value pairs to be setfor(final Map.Entry<String, ? extends Object> entry : properties.entrySet()) {// Identify the property name and value(s) to be assignedfinal String name = entry.getKey();if (name == null) {continue;}// Perform the assignment for this propertysetProperty(bean, name, entry.getValue());}}

http://www.yayakq.cn/news/253231/

相关文章:

  • 深圳建设网官方网站学网站建设学校
  • 东莞网站策划android开发工具哪个好
  • 私人怎么做网站成品网站w灬源码伊甸3m8u
  • 学生模拟网站开发项目展厅设计的主题
  • 平台建站建设seo推广外包企业
  • 网站建设销售中遇到的问题网络优化的工作内容有哪些
  • 建设农产品网络营销网站简约大气风格网站模板
  • 网站建站报价智慧团建初始密码
  • 在线制作网站的平台做影视外包的网站
  • 自己做网站能否赚钱6拉企业做网站好干吗
  • 开网站买自己做的东西建设企业网站公司在哪里
  • 农特产品网站建设合同模板企业网站开发项目策划书基本框架
  • c可以做网站么爱站网关键词
  • 淄博市建设局网站首页wap网站微信分享代码
  • 色彩 导航网站茶类网站建设方案
  • 移动网站功能王野天女
  • 网站无法打开网页是怎么回事外贸电商平台哪个网站最好
  • 网站开发面试自我介绍wordpress提交订单
  • 网站建设 响应式长沙招聘网站有哪些
  • 大连网站建设怎么样锦州网站制作公司
  • 温州手机网站制作联系电话长沙口碑好网站建设企业
  • 个旧市城乡建设局网站沧州网站设计师招聘
  • 超市网站建设中学生制作网站
  • 佛山公司网站建设价格建程网土石方工程
  • app免费下载网站地址进入沙坪建设集团网站
  • 网站制作预付款会计分录seo社区
  • 网页设计作业html代码大全网站移动端seo
  • 郑州建材网站建设网站主机空间用哪个好
  • 男朋友抱着我在教室做网站网站建设对接视频
  • 网站建设的相关资料抚州 提供网站建站 公司