Skip to content

BeanUtilsAssist is an improved extension of the populate method of the traditional org.apache.commons.beanutils.BeanUtils class.

License

Notifications You must be signed in to change notification settings

tang-jie/BeanUtilsAssist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BeanUtilsAssist

BeanUtilsAssist is an improved extension of the populate method of the traditional org.apache.commons.beanutils.BeanUtils class.

BeanUtilsAssist简介:

BeanUtilsAssist是对传统org.apache.commons.beanutils.BeanUtils类的populate方法的一种改进扩展。

  • 支持由于某些历史原因遗留下来的JavaBean,其属性命名带下划线的变量,对应的getter/setter方法为Java标准的lowerCamelCase命名规则。
  • 具体来说,传统意义上的org.apache.commons.beanutils.BeanUtils类的populate方法,JavaBean中属性命名带下划线,其对应的getter/setter方法只能如下:
class Person{
	private String user_id;
	
	// 这种方法名看上去有点low
	public String getUser_id() {
	    return user_id;
	}
	
	// 这种方法名看上去有点low 
	public void setUser_id(String user_id) {
	    this.user_id = user_id;
	}
}
  • 优化后兼容如下的JavaBean形式:
class Person{
	private String user_id;
	
	//这种方法名看上去至少顺眼
	public String getUserId() {
	    return user_id;
	}
	
	//这种方法名看上去至少顺眼
	public void setUserId(String user_id) {
	    this.user_id = user_id;
	}
}
  • 但是终归是兼容,更稳妥的做法是整个JavaBean设计,全部按照标准的lowerCamelCase命名规则来定义才是更稳妥的做法。

Author

唐洁(tangjie) http://www.cnblogs.com/jietang/


License

Apache License, Version 2.0 Copyright (C) 2017 Newland Group Holding Limited

About

BeanUtilsAssist is an improved extension of the populate method of the traditional org.apache.commons.beanutils.BeanUtils class.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages