MCPcopy Create free account
hub / github.com/LianjiaTech/json-diff / AlgorithmEnum

Enum AlgorithmEnum

src/main/java/com/ke/diff/AlgorithmEnum.java:17–82  ·  view source on GitHub ↗

算法模型枚举类:提供一些默认实现的算法模型 @Author JingWei @create 2022/3/2

Source from the content-addressed store, hash-verified

15 * @create 2022/3/2
16 */
17public enum AlgorithmEnum {
18
19 /**
20 * 默认的比较算法模型
21 */
22 DEFAULT(defaultAlgorithmModule()),
23
24 /**
25 * 数组比较采用Simple,对象比较采用Simple
26 */
27 SIMPLE_ARRAY_AND_SIMPLE_OBJECT(simpleAndSimpleAlgorithmModule()),
28
29 /**
30 * 数组比较采用Simple,对象比较采用LeftJoin
31 */
32 SIMPLE_ARRAY_AND_LEFTJOIN_OBJECT(simpleAndLeftJoinAlgorithmModule()),
33
34 /**
35 * 数组比较采用Similar,对象比较采用LeftJoin
36 */
37 SIMLAR_ARRAY_AND_LEFTJOIN_OBJECT(similarAndLeftJoinAlgorithmModule()),
38
39 /**
40 * 数组比较采用Similar,对象比较采用Simple
41 */
42 MOST_COMMONLY_USED(similarAndSimpleAlgorithmModule());
43
44 final private AlgorithmModule algorithmModule;
45
46 AlgorithmEnum(AlgorithmModule algorithmModule) {
47 this.algorithmModule = algorithmModule;
48 }
49
50
51 public AlgorithmModule getAlgorithmModule() {
52 return algorithmModule;
53 }
54
55 private static AlgorithmModule defaultAlgorithmModule() {
56 return new AlgorithmModule(new SimpleObjectComparator(), new SimilarArrayComparator(),
57 new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
58
59 }
60
61 private static AlgorithmModule simpleAndSimpleAlgorithmModule() {
62 return new AlgorithmModule(new SimpleObjectComparator(), new SimpleArrayComparator(),
63 new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
64 }
65
66
67 private static AlgorithmModule simpleAndLeftJoinAlgorithmModule() {
68 return new AlgorithmModule(new LeftJoinObjectComparator(), new SimpleArrayComparator(),
69 new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());
70 }
71
72 private static AlgorithmModule similarAndLeftJoinAlgorithmModule() {
73 return new AlgorithmModule(new LeftJoinObjectComparator(), new SimilarArrayComparator(),
74 new DefaultPrimitiveComparator(), new DefaultNullComparator(), new DefaultOtherComparator());

Callers

nothing calls this directly

Tested by

no test coverage detected