1. org.springframework.util.Assert (spring-core-4.1.6.RELEASE.jar)
判断一些参数是否符合条件。比如是否为空,是否有数据,如果没有就残暴地抛出异常。
isTrue为真,isNull为空,notNull不为空,hasLength有长度,hasText有内容(全空白字符不算),doesNotContain不包含某些字符串,notEmpty数组不为空(它本身不为空,并且数组长度不为0),noNullElements没有空无素,
notEmpty集合不为空,isInstanceOf是它的实例,isAssignable是子类或者说实现了该接口。2016-03-12 10:56:02
2. net.sf.oval.Validator.Validator() (oval-1.84.jar)
public class VaildateTestObject { @NotNull @NotEmpty @Length(min=2, max=32) private String name; public String getName() { return this.name; } public void setName(String name) { this.name = name; } public static void main(String[] args) { Validator validator = new Validator(); VaildateTestObject v = new VaildateTestObject(); v.setName("1"); List<ConstraintViolation> validates = validator.validate(v); for (ConstraintViolation constraintViolation : validates) System.out.println(constraintViolation.getMessage()); } }
这个例子是在项目中看到的,引过来了。2016-03-12 20:09:54
@MemberOf({"REGIST", "DELETE", "UPDATE"})
private String action; 枚举
3. Gson
Gson gson = new Gson(); System.out.println(gson.toJson(response));
JSON序列化。2016-03-12 20:28:31