Package org.aoju.bus.core.builder
Class ReflectionBuilder
java.lang.Object
org.aoju.bus.core.builder.ReflectionBuilder
- All Implemented Interfaces:
Serializable,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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.aoju.bus.core.builder.Builder
Builder.HashKey -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()包装唯一键(System.identityHashCode())使对象只有和自己 equals 此对象用于消除小概率下System.identityHashCode()产生的ID重复问题
-
Constructor Details
-
ReflectionBuilder
使用指定样式为指定对象构造一个生成器如果
lhs == rhs或lhs.equals(rhs), 则构建器将不计算对append(…)的任何调用, 并在build()执行时返回一个空的DifferentResult.- Type Parameters:
T- 要区分的对象的类型- Parameters:
lhs-this对象rhs- 反对的对象style- 当输出对象时将使用该样式,null使用默认值
-
-
Method Details
-
build
Description copied from interface:Builder包装唯一键(System.identityHashCode())使对象只有和自己 equals 此对象用于消除小概率下System.identityHashCode()产生的ID重复问题- Specified by:
buildin interfaceBuilder<DifferentResult>- Returns:
- 被构建的对象
-