JaVers Diff工具。预印有用吗?
构建jbJaVers Diff工具。预印有用吗?,javers,Javers,构建jb JaversBuilder jb = JaversBuilder.javers().withMappingStyle(MappingStyle.BEAN).withListCompareAlgorithm(ListCompareAlgorithm.LEVENSHTEIN_DISTANCE).withPrettyPrint(true) 然后 log.info(diff.prettyPrint()) 给予 ,但预期格式很好。就像在文档中一样- 我做错了什么? 我应该期望文档中显示的格式
JaversBuilder jb = JaversBuilder.javers().withMappingStyle(MappingStyle.BEAN).withListCompareAlgorithm(ListCompareAlgorithm.LEVENSHTEIN_DISTANCE).withPrettyPrint(true)
然后
log.info(diff.prettyPrint())
给予
,但预期格式很好。就像在文档中一样-
我做错了什么?
我应该期望文档中显示的格式很好,还是手动格式化?在您所指的文档中,换行符是手动添加的
diff.toString()
和diff.prettyPrint()
(因为它只是别名)
在每次更改后添加br。
因此,即使是包含一系列元素更改的ListChange也可以在一行中打印
使用
自定义差异格式。请参见示例在您所指的文档中,已手动添加换行符
diff.toString()
和diff.prettyPrint()
(因为它只是别名)
在每次更改后添加br。
因此,即使是包含一系列元素更改的ListChange也可以在一行中打印
使用
自定义差异格式。参见示例现在我必须使用regex `公共静态字符串预打印(Diff Diff){String out=Diff.prettyPrint()out=out.replaceAll(“\{globalId:”,“\{\n\tglobalId:”)out=out.replaceAll(“,属性:”,\n\t属性:”)out=out.replaceAll(“(\(\\d)”,“\n\t\t(\$1”)out=out.replaceAll(“'>>”,“\n\t\t>>”)return out}`现在我必须用正则表达式'public static String prettyPrint(Diff Diff){String out=Diff.prettyPrint()out=out.replaceAll(“\{globalId:”,“\\{\n\tglobalId:”)out=out.replaceAll(“,属性:”,\n\tproperty:)out=out.replaceAll(“\(\\d)\)。”,“\n\t\t\(\$1\)”)out=out.replaceAll(“'>>”,“\n\t\t>>”)返回}`
1. ListChange{globalId:'fn.dsl.diff.javers.Instance/Folder:{0F1E2D3C-4B5A-6978-8796-A5B4C3D2E1F0}', property:'permissions', containerChanges:[(3).removed:'fn.dsl.diff.javers.Permission {type: 'ALLOW', mask: '135159', GN: 'entos_users_tst@tn.fntst.ru', GT: 'GROUP', source: 'DIRECT', depth: 'THIS_OBJECT_ONLY' }', (2).'fn.dsl.diff.javers.Permission {type: 'ALLOW', mask: '999415', GN: 'entos_admins_tst@tn.fntst.ru', GT: 'GROUP', source: 'DIRECT', depth: 'THIS_OBJECT_ONLY' }' to 'fn.dsl.diff.javers.Permission {type: 'ALLOW', mask: '135159', GN: 'entos_users_tst@tn.fntst.ru', GT: 'GROUP', source: 'DIRECT', depth: 'THIS_OBJECT_ONLY' }']}
System.out.println(diff);
//.. shouldDetectBossChange()
Diff:
1. ReferenceChange{
globalId:'org.javers.core.examples.model.Employee/Great Developer',
property:'boss',
oldRef:'org.javers.core.examples.model.Employee/Manager One',
newRef:'org.javers.core.examples.model.Employee/Manager Second'}
2. ListChange{
globalId:'org.javers.core.examples.model.Employee/Manager Second',
property:'subordinates',
containerChanges: [(0).added:'org.javers.core.examples.model.Employee/Great Developer']}
3. ListChange{
globalId:'org.javers.core.examples.model.Employee/Manager One',
property:'subordinates',
containerChanges:[(0).removed:'org.javers.core.examples.model.Employee/Great Developer']}