Class ReflectionBuilder

java.lang.Object
org.aoju.bus.core.builder.ReflectionBuilder
All Implemented Interfaces:
Serializable, Builder<DifferentResult>

public class ReflectionBuilder extends Object implements Builder<DifferentResult>
协助实现Differentable.diff(Object)方法.

使用反射发现要差异的对象的所有非静态、非瞬态字段(包括继承字段),并比较它们之间的差异.

 public class Person implements Diffable<Person> {
   String name;
   int age;
   boolean smoker;
   ...

   public DiffResult diff(Person object) {
     return new ReflectionDiffBuilder(this, object, ToStringStyle.SHORT_PREFIX_STYLE)
       .build();
   }
 }
 

传递给构造函数的ToStringStyle嵌入到返回的DiffResult中, 并影响DiffResult. tostring()方法的风格。可以通过调用 DifferentResult.toString(ToStringStyle)覆盖此样式选择.

Since:
Java 17+
Author:
Kimi Liu
See Also: