1、注解
import java.lang.annotation.*;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface PropertyMsg {
String value();
}
2、实体类如何使用注解
3、比较方法
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Date;
public class LogUtils {
/**
*
* @param fields
* @param pojo1
* @param pojo2
* @param str
* @param clazz
* @return
*/
public static String objComparison(Field[] fields, Object pojo1, Object pojo2, StringBuilder str, Class clazz) {
try {
for (Field field : fields) {
if (field.isAnnotationPresent(PropertyMsg.class)) {