Skip to content

calm04061/class-helper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

class-helper

基于javassist类修改工具包

可以动态的创建类
动态修改类

	ClassHelper helper = ClassHelper.getHelper();
	ClassHelper make = helper.makeClass("com.calm.javassist.test.Bean");
	FieldHelper idField = make.addField("private String id;");
	MethodHelper methodHelper = make.addGetMethod("getId", idField);
	AnnationHelper<MethodHelper> annationHelper = methodHelper.addAnnation(JSONField.class);
	annationHelper.addBooleanMember("serialize", false)
		.addBooleanMember("deserialize", false)
		.addStringMember("name", "test")
		.end();
	Class<?> clazz  = make.toClass();
	Method method = clazz.getMethod("getId");
	JSONField annotation = method.getAnnotation(JSONField.class);
	System.out.println(annotation);

About

动态类修改工具包

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages