A method and device for comparing multiple data before and after based on custom annotations

Through the multiple data front and back comparison method based on custom annotations, efficient data comparison is achieved using HashMap and annotation classes, which solves the problem of inefficiency in the big data environment of the existing technology and improves the efficiency and scalability of data comparison.

CN119760571APending Publication Date: 2025-04-04SHENZHEN ANSHU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411882165.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-19
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Existing data comparison technology is inefficient in big data environments and is difficult to meet the needs of version tracking, change analysis and differential positioning.

Method used

Using a multiple data front and back comparison method based on custom annotations, the comparison results are stored through the HashMap data structure, and the field values ​​are compared one by one and different types of comparison results are generated. The field values ​​are extracted using the preset annotation class to achieve flexible field mapping.

Benefits of technology

It improves the efficiency and scalability of data comparison, can flexibly handle complex comparison requirements, reduces hard-coded requirements, and enhances the maintainability and scalability of code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760571A_ABST
    Figure CN119760571A_ABST
Patent Text Reader

Abstract

The present invention relates to the field of data comparison technology, and in particular to a method and device for comparing multiple data before and after based on custom annotations. The method comprises the following steps: creating a HashMap data structure; obtaining a first entity object and a second entity object; extracting field information from the first entity object and the second entity object to obtain a temporary field list; extracting field values ​​from the temporary field list through a preset annotation class to obtain a field value list; comparing the first entity field value and the second entity field value in the field value list field value one by one, and generating a first comparison result when the first entity field value is equal to the second entity field value. The present invention improves the efficiency and extensibility of data before and after comparison through custom annotations, dynamic comparison logic and support for multiple data types.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data comparison, and in particular to a method and device for comparing multiple data before and after based on user-defined annotations. Background Art

[0002] Data comparison technology is a common requirement in software engineering. It is used to track and manage data changes and ensure data consistency and accuracy. In traditional data comparison methods, developers usually rely on manually writing a lot of code logic to achieve data history tracking and version comparison. This method is not only time-consuming and labor-intensive, but also difficult to maintain and expand, and prone to errors. With the popularization of object-oriented programming ideas, annotation technology has gradually become an important tool in software development. Annotations allow developers to add metadata to the code, which is dynamically parsed and processed at runtime through reflection mechanisms, reducing hard-coded dependencies and improving code flexibility. Early annotation technology was mainly used in scenarios such as framework configuration and dependency injection. As its application deepened, developers began to explore how to use annotations to achieve automated operations in the field of data management. In the context of big data and complex business systems, data comparison is no longer limited to single fields or simple data set changes. The system needs a general, flexible and efficient multiple data comparison method to meet the needs of version tracking, change analysis and difference location. However, at present, most data comparison technologies rely on traditional database triggers or manual coding, which is often cumbersome and inefficient in big data environments. Summary of the invention

[0003] Based on this, it is necessary to provide a method and device for comparing multiple data before and after based on custom annotations to solve at least one of the above technical problems.

[0004] To achieve the above purpose, a method for comparing multiple data before and after based on custom annotations is provided, the method comprising the following steps: Step S1: Create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; Step S2: comparing the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, generating a first comparison result; when the first entity field value is not equal to the second entity field value, generating a second comparison result based on the value difference that the first entity field value is not equal to the second entity field value; Step S3: The first comparison result and the second comparison result are returned to the HashMap data structure for result return to obtain the final comparison result.

[0005] The present invention can efficiently manage the intermediate results and final results in the comparison process by using a HashMap data structure to store the comparison results of entity objects and field values, avoid repeated calculations, and save calculation time. By comparing field values ​​one by one and generating different types of comparison results according to the differences, complex comparison requirements can be flexibly handled. For example, when two entity field values ​​are equal, a comparison result is generated; when the field values ​​are not equal, a comparison result based on the value difference is generated, thereby providing rich detailed information for subsequent processing and analysis. By using a preset annotation class to extract field values, flexible field mapping can be achieved, the demand for hard coding can be reduced, and the scalability and maintainability of the code can be enhanced. Annotations can conveniently mark the data fields to be extracted, simplifying the process of data extraction. Each step clearly defines the processing flow, such as field value extraction, field value comparison, result storage, etc., making the entire process easy to understand and debug. The various steps are independent of each other and work closely together, which enhances the readability and maintainability of the code. Due to the use of annotation classes and flexible field value comparison mechanisms, the system can easily adapt to the expansion of different entity objects and comparison requirements, reducing the complexity of modifying the code when facing new requirements. Therefore, the present invention improves the efficiency and scalability of data comparison by customizing annotations, dynamic comparison logic and supporting multiple data types.

[0006] Preferably, step S1 comprises the following steps: Step S11: Create a HashMap data structure; obtain the first entity object and the second entity object; Step S12: extracting field information from the first entity object and the second entity object through a reflection mechanism to obtain a temporary field list, wherein the temporary field list includes the first entity field name and the second entity field name; Step S13: traverse the field names of the temporary field list through the preset annotation class, and obtain the first entity field name and the field value corresponding to the first entity field name through reflection to obtain the first entity field value and the second entity field value; store the first entity field value and the second entity field value as data to generate a field value list.

[0007] The present invention extracts the field information of the first entity object and the second entity object through the reflection mechanism, and can automatically obtain the field name and the field value, thereby avoiding the cumbersome process of manually extracting the fields one by one. Combined with the HashMap data structure to store the field value, it is possible to efficiently manage and organize data, and improve the efficiency of comparison and subsequent processing. The reflection mechanism is combined with the preset annotation class to make the field extraction process more flexible and automatic. Only the annotation class needs to be defined and the required fields are marked, and the system can automatically extract the field value according to the annotation, avoiding cumbersome manual coding and field mapping, and enhancing the maintainability and scalability of the system. By obtaining a temporary field list through reflection and extracting the corresponding field value according to the field name, the field data of different entity objects can be flexibly processed without relying on a hard-coded field list. This mechanism enhances the adaptability of the system and can process entity objects of different structures. By generating and storing the field value list, the field value can be easily compared and operated in subsequent steps, avoiding repeated calculations and improving the performance of the system. The HashMap data structure storing the field value can easily and quickly find the corresponding field value according to the field name, further improving the operation efficiency. The combination of annotation and reflection makes the dynamic extraction and operation of fields more flexible. The system only needs to annotate the required fields, and the reflection mechanism automatically obtains the field name and field value, which greatly reduces the development workload and can quickly respond to changes in the field structure.

[0008] Preferably, creating a HashMap data structure includes: Introduce the HashMap class; Declare and create a HashMap instance based on the HashMap class to obtain a HashMap instance; import methods of the HashMap instance to generate a HashMap data structure, where the method import includes put method, get method, clear method and remove method.

[0009] The present invention provides a data storage method based on key-value pairs through HashMap, and its implementation is based on hash table, so the stored elements can be quickly accessed through key values. This efficient access performance makes the management and query of large amounts of data faster, especially when comparing, searching or updating data, the time complexity of HashMap is O(1), which improves the overall processing efficiency. The put method can store data in the form of key-value pairs, allowing new data to be added dynamically. Each key is unique in HashMap, so the insertion of duplicate data can be effectively avoided, ensuring the uniqueness and consistency of data. The get method can be used to quickly obtain the corresponding value through the key. This feature is very useful for subsequent field comparison or data retrieval, and related data can be quickly obtained for processing, which is particularly suitable for scenarios where data needs to be frequently searched. The clear and remove methods provide HashMap with the function of clearing data or deleting specific key-value pairs. The clear method can quickly clear all data, and the remove method can delete a single element according to the specified key, which enhances the flexibility and controllability of HashMap. This is particularly important for dynamically adjusting data structures, releasing memory or adjusting storage content. HashMap provides a simple way to manage field values ​​and other complex data. Through method import and instantiation, data can be easily organized into a structured storage method, avoiding manual management of complex array or list structures and reducing code complexity. Through HashMap's data storage and management method, more methods or extended functions can be easily added, such as merging multiple HashMaps, supporting thread-safe operations, etc., thereby improving the flexibility and scalability of the system.

[0010] Preferably, step S13 includes the following steps: Step S131: extracting class information from the first entity object and the second entity object according to the final comparison result to obtain first entity object class information and second entity object class information; extracting class fields from the first entity object class information and the second entity object class information to obtain first entity field arrays and second entity field arrays; Step S132: performing traversal loop enhancement on the first entity field array and the second entity field array to generate the first entity field enhancement array and the second entity field enhancement array; performing static field discrimination on the first entity field enhancement array and the second entity field enhancement array through a preset annotation class, and when a static field is identified, operating the corresponding static field without performing processing; Step S133: performing field accessibility settings on the non-static fields in the first entity field enhancement array and the second entity field enhancement array, and generating first entity field access setting data and second entity field access setting data; Step S134: Based on the first entity field access setting data and the second entity field access setting data, the field values ​​of the first entity field enhanced array and the second entity field enhanced array are respectively acquired to obtain the first entity field value and the second entity field value; the first entity field value and the second entity field value are stored as data to generate a field value list.

[0011] The present invention ensures the comprehensiveness and accuracy of data comparison by extracting class information and field information from the first entity object and the second entity object. The traversal loop enhancement of the field further strengthens the comparison capability, enables processing of different types of field data, and enhances the adaptability of the system to complex data structures. The discrimination and processing mechanism of static fields is increased. Through the special processing of static fields, the system can skip static fields when fields are enhanced, thereby avoiding unnecessary processing, improving efficiency and avoiding erroneous operations, and ensuring that static fields will not be modified or improperly operated. The field accessibility setting in step S133 enables the system to dynamically adjust the access mode to the field according to the access rights or visibility of the field, thereby ensuring the security and privacy protection of the data. This is particularly important for objects containing private fields or restricted access, which helps to improve the security and compliance of the system. By acquiring and storing field values ​​for non-static fields, valuable dynamic data can be provided for subsequent data comparison, analysis or processing. The storage of field values ​​in the field value list makes subsequent operations more efficient and well-organized, avoiding repeated calculations and data loss. Static field identification is performed on the field enhancement array through the preset annotation class, and dynamic data operations are performed in combination with the reflection mechanism, so that the system can handle entity objects of different types and structures, while avoiding unnecessary complex operations, thereby improving the flexibility and maintainability of the system.

[0012] Preferably, step S2 comprises the following steps: Step S21: comparing the first entity field value and the second entity field value in the field value list one by one, and generating a first comparison result when the first entity field value is equal to the second entity field value; Step S22: When the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value.

[0013] The present invention ensures that data comparison is meticulous and comprehensive by comparing field values ​​one by one. The value of each field is checked separately, so that the difference in field value between the first entity object and the second entity object can be accurately identified, thereby providing clear and reliable data support for subsequent processing. By distinguishing equal and unequal field values, the system is helped to process two types of comparison results separately. When the field values ​​are equal, a first comparison result is generated, indicating that the two entities are completely consistent in the field; and when the field values ​​are unequal, a second comparison result is generated, which is convenient for subsequent difference analysis and processing. This classification processing mechanism improves the accuracy and flexibility of data comparison. The second comparison result is generated based on the difference in field values, and can capture and quantify the inconsistency of field values. This provides detailed difference data for subsequent optimization or adjustment, and accurate correction or further analysis can be performed based on these differences, thereby enhancing the intelligence and accuracy of the system. By dividing the comparison of field values ​​into two situations of equality and inequality, not only the efficiency of the comparison operation is improved, but also the comparison logic is simplified. The system can quickly generate different comparison results through simple conditional judgment, thereby accelerating the data processing speed, and is particularly suitable for batch comparison of large amounts of data. The generated first comparison result and second comparison result can be used for different subsequent processing. For example, the first comparison result may be used to verify the consistency of the data, and the second comparison result can be used to analyze and correct the difference. This separate result generation mechanism provides higher flexibility and is convenient for application in different business needs. Dividing the comparison results into two categories facilitates the subsequent expansion and function enhancement of the system. For example, if more comparison rules or difference processing mechanisms need to be added in the future, they can be expanded on the existing structure without having to reconstruct the existing comparison process.

[0014] Preferably, comparing the first entity field value and the second entity field value in the field value list field value by field value comprises: Compare the first entity field value and the second entity field value in the field value list one by one by field value type, and generate field value type data, wherein the field value type data includes a first field type, a second field type, and a third field type, wherein the first field type is a LIST type, the second field type is an OBJECT type, and the third field type is a FIELD type; The first entity field value and the second entity field value in the field value list are compared field by field value through the first field type, the second field type and the third field type, and when the first entity field value is equal to the second entity field value, a first comparison result is generated.

[0015] The present invention can ensure that the data type of each field value is consistent with expectations by comparing the field value types one by one. This type-level comparison can effectively avoid the problem of data type mismatch and ensure that subsequent operations, calculations or logical judgments are performed on the basis of the correct data type. The generated field value type data (including the first field type, the second field type and the third field type) can describe the type information of each field value in detail, help the system or developers to identify possible type problems in real time during data processing, and ensure data consistency and integrity. This helps to avoid runtime errors caused by type incompatibility. By distinguishing between LIST type, OBJECT type and FIELD type, the system can flexibly deal with different types of field values. Each type of field value can have different processing strategies. For example, LIST type field values ​​may need to compare the elements of the collection one by one, OBJECT type may need to compare in depth, and FIELD type may be a basic type or a custom data structure. This type division provides a highly flexible subsequent processing method. By comparing the field types one by one, the system can clearly know how to perform comparison operations during the field value matching process. When the field value types are consistent, the values ​​can be compared directly; when the types are inconsistent, these mismatched type differences can be processed in advance to avoid errors or unnecessary operations. This refined processing method improves the accuracy of the comparison. When the field types are inconsistent, potential errors or inconsistencies can be effectively identified, thereby reducing the risk of errors caused by mismatched data types. This helps to improve the quality of data processing, especially when it involves complex data structures or cross-system data transmission, and can avoid the trouble caused by data format issues.

[0016] Preferably, comparing the first entity field value and the second entity field value in the field value list one by one by using the first field type comprises the following steps: The length of the first entity field value and the second entity field value in the field value list is judged by the first field type. If the length of the first entity field value in the field value list is equal to the length of the second entity field value, the second field type and the third field type are judged for the first entity field value and the second entity field value; If the length of the first entity field value in the field value list is equal to the length of the second entity field value, a length difference comparison is performed on the first entity field value that is equal to the second entity field value to generate a first comparison result.

[0017] The present invention ensures that two field values ​​are equal in length by length judgment. This step can effectively avoid unnecessary errors caused by inconsistent field value lengths. For example, if the lengths of two field values ​​are different, it means that there are differences in their content structures, and the system can identify them in advance and make corresponding processing. In this way, the system can focus on the data content itself in the subsequent field value comparison, rather than being disturbed by unnecessary length differences. By first judging the length of the field value, and then performing further field type discrimination and difference comparison, the comparison process can be optimized. The system does not have to perform lengthy comparisons on all field values, and only needs to perform detailed comparisons when confirming that the lengths are consistent. This method can improve efficiency and reduce invalid operations, especially when processing large-scale data, it can significantly improve the performance of the system. This step further determines whether to enter the discrimination of the second field type and the third field type by combining the length judgment of the first field type, and can adopt different comparison strategies for different types of field values. This enables the system to flexibly respond to comparisons of various data types, provide more accurate processing paths, and avoid unnecessary repeated operations. By performing length difference comparison, when the field value lengths do not match, the system can immediately identify the cause of the mismatch and generate a first comparison result. This method can accurately locate specific differences and provide valuable data for subsequent corrections or analysis, greatly reducing the difficulty of error analysis and debugging.

[0018] Preferably, comparing the first entity field value and the second entity field value in the field value list field value one by one by using the second field type comprises: A recursive field difference judgment is performed on the first entity field value and the second entity field value in the field value list through the second field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

[0019] The present invention can make an in-depth comparison of complex data structures by recursively distinguishing field values, especially when processing nested objects, set types, or multi-level data, the recursive comparison can accurately find the hierarchical differences between fields. The recursive mechanism can ensure that each layer of data of the field value is compared one by one, and no details are missed, ensuring the comprehensiveness of the comparison result. The recursive difference discrimination can accurately identify the subtle differences in the data structure. This is particularly important for the case where the data structure is relatively complex, such as nested objects or multi-level lists, and the recursive comparison can be accurate to each sub-level field, thereby ensuring the accuracy of the comparison and data consistency. The use of a recursive method can effectively process complex data structures, whether the data is a nested object, list, set, etc., can be compared by a unified recursive method. This method avoids the need to design complex comparison logic for each data type separately, and improves the reusability and extensibility of the code. Through recursive discrimination, when the field values ​​are equal, the differences are further compared, and this self-correcting comparison mechanism can automatically identify and process any inconsistencies in the field. Recursive difference discrimination not only improves the depth of comparison, but also gradually converges to accurate results at each comparison, avoiding missing or incorrectly processing certain fields. Recursive difference discrimination helps to gain a deeper understanding of potential sources of differences in the data, especially when the data is complex and there is a hierarchical relationship between fields. The system can accurately track differences and promptly discover potential errors or inconsistencies. This is critical for ensuring data quality, fixing data defects, or performing data cleansing. Although the recursive logic may increase some computational complexity, since recursion only further refines the comparison when the field values ​​are equal, it means that the system will only recursively operate on data that really needs a deep comparison, avoiding unnecessary computational waste. Therefore, this comparison method can both ensure accuracy and improve efficiency in some cases. The field data structures involved in many practical applications are usually multi-level objects or lists, and recursive methods can effectively handle hierarchical data types. Recursive comparison ensures that fields at each level are taken into account and compared according to their recursive levels, so that complex data structures can be accurately processed.

[0020] Preferably, comparing the first entity field value and the second entity field value in the field value list field value one by one by using the third field type comprises: The first entity field value and the second entity field value in the field value list are identified by using the third field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

[0021] The present invention can process complex data structures, such as nested objects, lists, or combination types composed of multiple fields, through field nesting difference discrimination. For such complex structures, nested difference discrimination ensures that the fields of each nested level are compared one by one, effectively identifying the differences at different levels, thereby improving the comprehensiveness of data comparison. Field nesting difference discrimination can go deep into each layer of nested fields and identify subtle differences. By accurately comparing each layer of nested fields, it is ensured that the comparison does not just stay at the top-level structure, but covers every detail of the data, which helps to find some potential and complex differences and improve the accuracy of data comparison. For multi-layer nested objects or collection types, nested difference discrimination helps to ensure the consistency of the entire data structure. When the values ​​of the nested fields are equal, the system will continue to compare each level of its internal structure to ensure the structural consistency of the entire data and enhance the ability of data consistency verification. Through nested difference discrimination, the details of each layer of data can be deeply understood, especially when processing complex data structures. This method can effectively distinguish the hierarchical relationship in the field and perform accurate difference comparison. This deep comparison helps to identify detail differences that cannot be found by conventional comparison methods. In the process of data comparison, nested difference discrimination can automatically find and report inconsistencies in the data. If the value of a nested field is inconsistent, the system can automatically generate a comparison result and provide repair suggestions or automatic adjustments based on the differences, thereby achieving automated data cleaning and repair. The field nesting difference judgment method has strong scalability. No matter how complex the data structure is, nested difference judgment can handle new field types or nesting levels. Therefore, as the data structure changes, the system can maintain a high degree of adaptability without the need to make major changes to the comparison logic.

[0022] In this specification, a device for comparing multiple data before and after based on custom annotations is provided, which is used to execute the above-mentioned method for comparing multiple data before and after based on custom annotations. The device for comparing multiple data before and after based on custom annotations includes: A field extraction module is used to create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; A data comparison module is used to compare the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, a first comparison result is generated; when the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value; The result display module is used to return the first comparison result and the second comparison result to the HashMap data structure for result return to obtain the final comparison result.

[0023] The beneficial effect of the present invention is that through the field extraction module, field information can be quickly and systematically extracted from the first entity object and the second entity object, reducing the possibility of manual intervention and errors. The field is automatically extracted using a preset annotation class, which improves the efficiency and accuracy of field information extraction and ensures that the extraction and processing of each field conform to the predetermined rules. The data comparison module can effectively identify the difference between the two entity objects by comparing the field values ​​one by one. When the field values ​​are equal, a first comparison result is generated, which helps to quickly locate the consistent fields; when the field values ​​are not equal, the system can generate a second comparison result based on the difference between the field values, thereby identifying the difference and improving the comprehensiveness and accuracy of the data comparison. By returning the first comparison result and the second comparison result to the HashMap data structure, the comparison results can be conveniently organized and stored. The HashMap data structure provides a flexible and efficient way for subsequent result query, update and processing, which helps to quickly access data and present results. The system can not only handle simple field value comparisons, but also support advanced data comparisons based on field value differences, and can provide the ability to perform in-depth comparisons on complex data structures (such as nested objects or collection types). In this way, the system can detect potential differences in details, especially for comparisons of complex data types and multi-layer nested structures. Therefore, the present invention improves the efficiency and scalability of data comparison by customizing annotations, dynamic comparison logic and supporting multiple data types. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a schematic diagram of the steps of a method for comparing multiple data before and after based on custom annotations; Figure 2 for Figure 1 Detailed implementation steps of step S1 in FIG. Figure 3 for Figure 2 Detailed implementation steps of step S13; The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0025] The technical method of the present invention is described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by technicians in this field without creative work are within the scope of protection of the present invention.

[0026] In addition, the accompanying drawings are only schematic illustrations of the present invention and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. The functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor methods and / or microcontroller methods.

[0027] It should be understood that, although the terms "first", "second", etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are used only to distinguish one unit from another unit. For example, without departing from the scope of the exemplary embodiments, the first unit may be referred to as the second unit, and similarly the second unit may be referred to as the first unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items.

[0028] To achieve this, please refer to Figures 1 to 3 , a method for comparing multiple data before and after based on custom annotations, the method comprising the following steps: Step S1: Create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; Step S2: comparing the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, generating a first comparison result; when the first entity field value is not equal to the second entity field value, generating a second comparison result based on the value difference that the first entity field value is not equal to the second entity field value; Step S3: The first comparison result and the second comparison result are returned to the HashMap data structure for result return to obtain the final comparison result.

[0029] The present invention can efficiently manage the intermediate results and final results in the comparison process by using a HashMap data structure to store the comparison results of entity objects and field values, avoid repeated calculations, and save calculation time. By comparing field values ​​one by one and generating different types of comparison results according to the differences, complex comparison requirements can be flexibly handled. For example, when two entity field values ​​are equal, a comparison result is generated; when the field values ​​are not equal, a comparison result based on the value difference is generated, thereby providing rich detailed information for subsequent processing and analysis. By using a preset annotation class to extract field values, flexible field mapping can be achieved, the demand for hard coding can be reduced, and the scalability and maintainability of the code can be enhanced. Annotations can conveniently mark the data fields to be extracted, simplifying the process of data extraction. Each step clearly defines the processing flow, such as field value extraction, field value comparison, result storage, etc., making the entire process easy to understand and debug. The various steps are independent of each other and work closely together, which enhances the readability and maintainability of the code. Due to the use of annotation classes and flexible field value comparison mechanisms, the system can easily adapt to the expansion of different entity objects and comparison requirements, reducing the complexity of modifying the code when facing new requirements. Therefore, the present invention improves the efficiency and scalability of data comparison by customizing annotations, dynamic comparison logic and supporting multiple data types.

[0030] In the embodiment of the present invention, reference Figure 1 FIG. 1 is a flow chart of the steps of a method for comparing multiple data before and after based on user-defined annotations according to the present invention. In this example, the method for comparing multiple data before and after based on user-defined annotations includes the following steps: Step S1: Create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; In the embodiment of the present invention, by creating a HashMap<String, Object> , used to store the mapping between field names (string type) and field values ​​(object type). For example, it is defined as: Map<String, Object> fieldValuesMap = new HashMap<>();There are two entity classes Entity1 and Entity2. Get the objects of these two entities through the constructor or other means. Use reflection to get all the field information of these two entity classes, including the name and type of the field. Reflection can get all the fields of the entity class through the getDeclaredFields() method: Use reflection technology to extract all the field information of these two entity objects. Reflection can get the member variables (fields) of the object, including the field name and its type. Field information is usually stored in a temporary field list. According to the preset annotation class (such as @FieldValue), identify the fields in the temporary field list. Only extract those field values ​​identified by specific annotations. Get the values ​​of these fields through reflection, and store the field names and field values ​​in HashMap. Finally, store all qualified field names and field values ​​in Map form, and get a list of field values. This list can be used for subsequent processing or operations.

[0031] Step S2: comparing the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, generating a first comparison result; when the first entity field value is not equal to the second entity field value, generating a second comparison result based on the value difference that the first entity field value is not equal to the second entity field value; In this embodiment of the present invention, the field values ​​of firstEntity and secondEntity are extracted through reflection and annotation, and these field values ​​are stored in a HashMap<String, Object> In this step, the field value list is traversed and the corresponding field values ​​in firstEntity and secondEntity are compared one by one. For each field, the field value in firstEntity is compared with the field value in secondEntity to see if they are equal. The field values ​​can be compared by the equals() method or other means. If the field value of firstEntity is equal to the field value of secondEntity, a first comparison result is generated. The field name and field value can be recorded, or a flag indicating a successful comparison can be returned according to actual needs. For example, a method can be called to generate a comparison result: if the field value of firstEntity is not equal to the field value of secondEntity, a second comparison result is generated. At this time, a comparison result needs to be generated based on the difference between the field values. Usually, the difference can be calculated by calculating the difference in numeric values ​​(such as numeric fields) or the difference in comparison objects (such as strings, dates, etc.). For example, for numeric type fields, the difference can be calculated, and the second comparison result is generated based on the difference in field values, recording the field name, field value, and the difference between them. Through the above steps, when the field values ​​in firstEntity and secondEntity are equal, a first comparison result is generated; when the field values ​​are not equal, a second comparison result is generated based on the difference between them. In actual operation, these comparison results can be returned according to requirements, or stored in other data structures for subsequent processing.

[0032] Step S3: The first comparison result and the second comparison result are returned to the HashMap data structure for result return to obtain the final comparison result.

[0033] In the embodiment of the present invention, the first comparison result and the second comparison result are returned to the HashMap. First, a HashMap needs to be prepared.<String, String> or HashMap<String, Object> to store the final comparison results. This HashMap will contain the comparison results for each field. For the first comparison result (field values ​​are equal), the corresponding comparison information can be stored in comparisonResultsMap. In the second comparison result (field values ​​are not equal with differences), the difference results are also recorded in HashMap. The specific operation is as follows: If the field value of firstEntity is equal to the field value of secondEntity, the information of successful comparison is returned to HashMap. If the field value of firstEntity is not equal to the field value of secondEntity, the field difference value and the information of failed comparison are returned to HashMap. For the case where the field values ​​are not equal, the difference between the field values ​​is calculated using the calculateDifference method defined earlier. You can decide how to calculate the difference based on the field type (such as number, string, etc.) and save the difference as a value. For example, for a number field, its absolute difference can be returned; for a string field, its length difference or the specific content of the difference can be returned. Once the comparison results of all fields are returned to the HashMap, the final comparison result can be obtained by returning the HashMap. This HashMap will contain the comparison status and related information for each field. Output these comparison results to the console, log file, or interface for user viewing or further processing. You can traverse the comparisonResultsMap and print the comparison results for each field: As an example of the present invention, refer to Figure 2 As shown, in this example, step S1 includes: Step S11: Create a HashMap data structure; obtain the first entity object and the second entity object; Step S12: extracting field information from the first entity object and the second entity object through a reflection mechanism to obtain a temporary field list, wherein the temporary field list includes the first entity field name and the second entity field name; Step S13: traverse the field names of the temporary field list through the preset annotation class, and obtain the first entity field name and the field value corresponding to the first entity field name through reflection to obtain the first entity field value and the second entity field value; store the first entity field value and the second entity field value as data to generate a field value list.

[0034] In the embodiment of the present invention, by creating a HashMap<String, Object> A data structure for storing field values ​​extracted from the first entity object and the second entity object. The key of this HashMap is the field name, and the value is the corresponding field value. Get the two entity objects to be compared, which are usually passed to the current operation method by the caller. In actual applications, these entity objects can be database records, API response data, or objects in other business logic. Using Java's reflection mechanism, get all the fields in the entity class through the Class object. Through reflection, you can dynamically get the field names of the entity class and their corresponding field values. The temporary field list contains the field names in each entity class. The field names can be obtained through the getName() method of the Field object. In order to ensure that the corresponding fields in the two entity classes are consistent, the field names are usually matched. The temporary field list is a collection of field names, and the field names can be stored in the list through a loop. Set a custom annotation class (such as @FieldName), which can be added to the field to identify the specific attributes of the field. In this step, the reflection mechanism will be used to check whether each field has the annotation and traverse each field. When traversing the fields, use reflection to get the field value of each field in firstEntity and secondEntity. To do this, you need to call setAccessible(true) to access private fields. Then use the get() method to get the value of the field. Store the value of each field in fieldValuesMap. This HashMap uses the field name as the key and the field value as the value to store the field values ​​in firstEntity and secondEntity, which is convenient for subsequent comparison operations. For example, the field value can be stored in the following format: fieldValuesMap.put("fieldName_first", firstFieldValue);fieldValuesMap.put("fieldName_second", secondFieldValue); Finally, the fieldValuesMap will contain all the field names and their corresponding field values, and the HashMap can be returned for use in subsequent steps.

[0035] Preferably, creating a HashMap data structure includes: Introduce the HashMap class; Declare and create a HashMap instance based on the HashMap class to obtain a HashMap instance; import methods of the HashMap instance to generate a HashMap data structure, where the method import includes put method, get method, clear method and remove method.

[0036] In the embodiment of the present invention, in the Java program, the HashMap class is located in the java.util package. Therefore, the HashMap class needs to be introduced first. By declaring a variable of the HashMap type and instantiating a HashMap object through the new keyword.<String, Object> The data type of the key-value pair is specified, where the key (String) is used to identify the field name and the value (Object) is used to store the corresponding data. At this time, hashMapInstance is a HashMap instance with basic functional operations. By calling the core methods (put, get, clear, and remove) provided by HashMap, data storage, data query, data clearing, and data deletion operations are implemented to generate a complete HashMap data structure. Using the put method, you can store key-value pairs in the HashMap. Using the get method, you can get the corresponding value according to the specified key. Using the clear method, you can clear all key-value pairs in the HashMap. Using the remove method, you can delete the corresponding key-value pair in the HashMap according to the specified key. Integrate the above steps into a complete example to implement the creation and method operations of the HashMap data structure.

[0037] As an example of the present invention, refer to Figure 3 As shown, in this example, step S13 includes: Step S131: extracting class information from the first entity object and the second entity object according to the final comparison result to obtain first entity object class information and second entity object class information; extracting class fields from the first entity object class information and the second entity object class information to obtain first entity field arrays and second entity field arrays; Step S132: performing traversal loop enhancement on the first entity field array and the second entity field array to generate the first entity field enhancement array and the second entity field enhancement array; performing static field discrimination on the first entity field enhancement array and the second entity field enhancement array through a preset annotation class, and when a static field is identified, operating the corresponding static field without performing processing; Step S133: performing field accessibility settings on the non-static fields in the first entity field enhancement array and the second entity field enhancement array, and generating first entity field access setting data and second entity field access setting data; Step S134: Based on the first entity field access setting data and the second entity field access setting data, the field values ​​of the first entity field enhanced array and the second entity field enhanced array are respectively acquired to obtain the first entity field value and the second entity field value; the first entity field value and the second entity field value are stored as data to generate a field value list.

[0038] In the embodiment of the present invention, the class information of the first entity object and the second entity object is extracted by using the reflection mechanism and the class information of the first entity object and the class information of the second entity object is obtained by the getClass() method. The getClass() method can return the Class type of the object for subsequent field extraction operations. Here, Class<?> Represents a generic class type to ensure compatibility. Use the getDeclaredFields() method to extract all fields of the first entity class and the second entity class, including private fields, and generate the first entity field array and the second entity field array. getDeclaredFields() returns all declared fields in the class (excluding fields of the parent class). The obtained field array contains information such as field name and field type, which is convenient for subsequent operations. The first entity field array and the second entity field array are traversed and looped, and the traversal results are stored in the enhanced field array to lay the foundation for subsequent processing. Use the Modifier.isStatic() method to determine whether the field is a static field. If it is a static field, filter it to avoid subsequent operations on the static field. The Modifier.isStatic() method is used to determine whether the field has a static modifier. The purpose of filtering static fields is to perform subsequent comparison and extraction operations only on instance fields to avoid interference. In the enhanced field array, set the accessibility of the field to true to ensure that the value of the private field can be obtained. The setAccessible(true) method can break the access permission restrictions of the field and allow access to private fields. The accessibility setting of the field is a prerequisite for obtaining the field value in the reflection operation. After the accessibility setting, all non-static fields are in an accessible state, forming the first entity field access setting data and the second entity field access setting data. Use the Field.get(Object obj) method to extract the field value from the first entity object and the second entity object based on the accessibility setting data, and associate the field name with the field value. By traversing the enhanced field array, call the Field.get() method one by one to obtain the field value. Store the field name and the corresponding field value in the HashMap to form a key-value pair relationship for subsequent processing. The key name is distinguished from the field name by splicing the entity identifier (such as FirstEntity_ and SecondEntity_) to avoid naming conflicts. Store the extracted field values ​​in the HashMap data structure to generate a field value list.

[0039] Preferably, step S2 comprises the following steps: Step S21: comparing the first entity field value and the second entity field value in the field value list one by one, and generating a first comparison result when the first entity field value is equal to the second entity field value; Step S22: When the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value.

[0040] In an embodiment of the present invention, the field values ​​of the first entity and the second entity in the field value list are traversed to compare the field values ​​one by one. The field values ​​of the first entity and the second entity are extracted one by one by using a for loop and field key value mapping. The HashMap data structure is traversed to extract the field values ​​corresponding to the first entity and the second entity for comparison. The fields are distinguished by string prefixes (FirstEntity_ and SecondEntity_) to ensure that the corresponding fields match one by one. If the field values ​​are equal, the comparison results are stored in firstComparisonResults. The comparison results are stored in the HashMap in the form of field name-result description to form a first comparison result set. The difference analysis is performed on the unequal field values ​​to generate a second comparison result. The specific difference between the first entity field value and the second entity field value is compared, and the field name and the corresponding difference information are recorded. If the first entity field value and the second entity field value are not equal or one of them is empty, the difference is recorded. The second comparison result is stored in the form of field name-difference description to record the difference details. The difference analysis results are stored in the HashMap to facilitate subsequent operations. The first comparison result and the second comparison result are summarized so as to return the final comparison result in a subsequent step.

[0041] Preferably, comparing the first entity field value and the second entity field value in the field value list field value by field value comprises: Compare the first entity field value and the second entity field value in the field value list one by one by field value type, and generate field value type data, wherein the field value type data includes a first field type, a second field type, and a third field type, wherein the first field type is a LIST type, the second field type is an OBJECT type, and the third field type is a FIELD type; The first entity field value and the second entity field value in the field value list are compared field by field value through the first field type, the second field type and the third field type, and when the first entity field value is equal to the second entity field value, a first comparison result is generated.

[0042] In the embodiment of the present invention, type classification processing is performed on the first entity field value and the second entity field value in the field value list. The types of field values ​​are divided into three categories: the first field type: LIST type (such as ArrayList or LinkedList collection types). The second field type: OBJECT type (custom object or non-basic data type). The third field type: FIELD type (basic data type or simple field type, such as int, String, etc.). The type of the field value is dynamically judged through the reflection mechanism to generate field value type data. For the field value of LIST type, each element is compared. If the lengths of the two LISTs are different, the difference is recorded. If the lengths are the same, the values ​​are compared element by element. For the field value of OBJECT type, the internal field values ​​are recursively compared through reflection. All fields in the object are extracted and the field values ​​are compared one by one. If there are differences in the internal field values, the specific difference information is recorded. For basic data types, strings or numeric types, value comparison is performed directly. Value comparison is performed according to the field type (LIST, OBJECT, FIELD), and the comparison results are finally stored in the HashMap data structure. If the field values ​​are equal, a first comparison result is generated; otherwise, a difference description is generated.

[0043] Preferably, comparing the first entity field value and the second entity field value in the field value list one by one by using the first field type comprises the following steps: The length of the first entity field value and the second entity field value in the field value list is judged by the first field type. If the length of the first entity field value in the field value list is equal to the length of the second entity field value, the second field type and the third field type are judged for the first entity field value and the second entity field value. If the length of the first entity field value in the field value list is equal to the length of the second entity field value, a length difference comparison is performed on the first entity field value that is equal to the second entity field value to generate a first comparison result.

[0044] In an embodiment of the present invention, the length of the field value of the first field type (LIST type) is judged: If the lengths of the two field values ​​are equal: enter the second step to distinguish the second field type and the third field type. If the lengths of the two field values ​​are not equal: perform a length difference comparison, and directly generate a first comparison result, indicating that the lengths of the two LIST type field values ​​are different. If the lengths are equal, perform element-level type discrimination on the two LIST type field values: Second field type (OBJECT type): perform further reflective comparison on each object field. Third field type (FIELD type): perform direct value comparison on each basic data type (such as int, String).

[0045] Preferably, comparing the first entity field value and the second entity field value in the field value list field value one by one by using the second field type comprises: A recursive field difference judgment is performed on the first entity field value and the second entity field value in the field value list through the second field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

[0046] In an embodiment of the present invention, the difference is determined by recursive field: if the first entity field value in the field value list is equal to the second entity field value: proceed to the next step and perform a difference comparison. If the first entity field value in the field value list is not equal to the second entity field value: directly generate a difference comparison result, indicating that the field values ​​are inconsistent, and return the comparison result. If the object field values ​​are equal, continue to determine whether there are internal field differences. Recursively check whether the field values ​​are different, and compare them layer by layer until all fields are compared. The specific recursive logic is as follows: determine the type of the field value to determine whether recursion is required: when the field is an object type, the recursive method will be called to continue to enter the next layer of field comparison. Each time a new field is entered, it is necessary to obtain the value of the field and check whether it is a basic type. If it is a basic type, compare directly; if it is an object type, recursively continue to check its internal fields. The termination condition of the recursion is very important. The recursive call should terminate when encountering a basic data type, because these data types no longer have subfields to recurse. Once each layer of the recursion has completed the field comparison, the recursion will return the comparison results layer by layer. If a difference is found (that is, the two field values ​​are not equal), a difference record is generated and the result is finally returned to the caller.

[0047] Preferably, comparing the first entity field value and the second entity field value in the field value list field value one by one by using the third field type comprises: The first entity field value and the second entity field value in the field value list are identified by using the third field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

[0048] In an embodiment of the present invention, when a field in a field value list is of a third field type (e.g., FIELD type, indicating a field type containing finer granularity or deeper nesting), it is necessary to perform more complex difference discrimination on these fields, especially to compare the field nesting structure. The following is a detailed implementation method of the process: In this context, the third field type generally refers to fields with nested structures, such as objects or values ​​contained in List or Map. Object fields contained in objects, these objects may be more complex in structure. For example, nested entity class fields, objects in a collection, or nested objects in a mapping table. Therefore, the core feature of the third field type is that it contains other fields or objects, which may be collection types (such as List, Set, Map) or complex nested objects. When comparing field values ​​one by one through the third field type, the main goal of the comparison is to identify the differences between the fields, especially at the level of field nesting. The following are specific implementation steps: First, check the type of the field value to determine whether it belongs to the third field type: If the field type is a collection type (such as List, Map, Set) or a custom object type, it is considered that the field belongs to the third field type and may contain a nested structure. For each field of the third field type, determine its internal structure and further compare the differences of the nested fields: if the field contains nested objects or collection elements, recursively enter the nested fields to determine the differences. For collection type fields (such as List, Set), first compare the size of the collection, and then compare the collection elements one by one. For object fields, recursively call the same comparison logic and enter the internal fields of the object for comparison. If the field value belongs to a nested object (Object type) or a collection type (List, Map), you need to enter these structures and compare the field values ​​layer by layer. During the comparison process: If the two are equal, continue to recursively compare the nested fields. If there is a difference (for example, the field values ​​are different), record the difference. After completing the recursive comparison, generate the comparison results based on the differences of the nested fields, record which fields are the same and which fields are different, and save the difference records.

[0049] In this specification, a device for comparing multiple data before and after based on custom annotations is provided, which is used to execute the above-mentioned method for comparing multiple data before and after based on custom annotations. The device for comparing multiple data before and after based on custom annotations includes: A field extraction module is used to create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; A data comparison module is used to compare the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, a first comparison result is generated; when the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value; The result display module is used to return the first comparison result and the second comparison result to the HashMap data structure for result return to obtain the final comparison result.

[0050] The beneficial effect of the present invention is that through the field extraction module, field information can be quickly and systematically extracted from the first entity object and the second entity object, reducing the possibility of manual intervention and errors. The field is automatically extracted using a preset annotation class, which improves the efficiency and accuracy of field information extraction and ensures that the extraction and processing of each field conform to the predetermined rules. The data comparison module can effectively identify the difference between the two entity objects by comparing the field values ​​one by one. When the field values ​​are equal, a first comparison result is generated, which helps to quickly locate the consistent fields; when the field values ​​are not equal, the system can generate a second comparison result based on the difference between the field values, thereby identifying the difference and improving the comprehensiveness and accuracy of the data comparison. By returning the first comparison result and the second comparison result to the HashMap data structure, the comparison results can be conveniently organized and stored. The HashMap data structure provides a flexible and efficient way for subsequent result query, update and processing, which helps to quickly access data and present results. The system can not only handle simple field value comparisons, but also support advanced data comparisons based on field value differences, and can provide the ability to perform in-depth comparisons on complex data structures (such as nested objects or collection types). In this way, the system can detect potential differences in details, especially for comparisons of complex data types and multi-layer nested structures. Therefore, the present invention improves the efficiency and scalability of data comparison by customizing annotations, dynamic comparison logic and supporting multiple data types.

[0051] Therefore, the embodiments should be regarded as illustrative and non-restrictive from all points, and the scope of the present invention is limited by the appended claims rather than the above description, and it is therefore intended that all changes falling within the meaning and range of equivalent elements of the application documents are included in the present invention.

[0052] The above description is only a specific embodiment of the present invention, so that those skilled in the art can understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but should conform to the widest scope consistent with the principles and novel features invented herein.

Claims

1. A method for comparing multiple data before and after based on custom annotations, characterized in that: The following steps are involved: Step S1: Create a HashMap data structure; obtain the first entity object and the second entity object; Extracting field information from the first entity object and the second entity object to obtain a temporary field list; extracting field values ​​from the temporary field list through a preset annotation class to obtain a field value list; Step S2: comparing the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, generating a first comparison result; when the first entity field value is not equal to the second entity field value, generating a second comparison result based on the value difference that the first entity field value is not equal to the second entity field value; Step S3: The first comparison result and the second comparison result are returned to the HashMap data structure for result return to obtain the final comparison result.

2. The method for comparing multiple data before and after based on user-defined annotations according to claim 1, characterized in that: Step S1 includes the following steps: Step S11: Create a HashMap data structure; obtain the first entity object and the second entity object; Step S12: extracting field information from the first entity object and the second entity object through a reflection mechanism to obtain a temporary field list, wherein the temporary field list includes the first entity field name and the second entity field name; Step S13: traverse the field names of the temporary field list through the preset annotation class, and obtain the first entity field name and the field value corresponding to the first entity field name through reflection to obtain the first entity field value and the second entity field value; store the first entity field value and the second entity field value as data to generate a field value list.

3. The method for comparing multiple data before and after based on user-defined annotations according to claim 2, characterized in that: Creating a HashMap data structure involves: Introduce the HashMap class; Declare and create a HashMap instance based on the HashMap class to obtain a HashMap instance; import methods of the HashMap instance to generate a HashMap data structure, where the method import includes put method, get method, clear method and remove method.

4. The method for comparing multiple data before and after based on user-defined annotations according to claim 2, characterized in that: Step S13 includes the following steps: Step S131: extracting class information from the first entity object and the second entity object according to the final comparison result to obtain first entity object class information and second entity object class information; extracting class fields from the first entity object class information and the second entity object class information to obtain first entity field arrays and second entity field arrays; Step S132: performing traversal loop enhancement on the first entity field array and the second entity field array to generate the first entity field enhancement array and the second entity field enhancement array; performing static field discrimination on the first entity field enhancement array and the second entity field enhancement array through a preset annotation class, and when a static field is identified, operating the corresponding static field without performing processing; Step S133: performing field accessibility settings on the non-static fields in the first entity field enhancement array and the second entity field enhancement array, and generating first entity field access setting data and second entity field access setting data; Step S134: Based on the first entity field access setting data and the second entity field access setting data, the field values ​​of the first entity field enhanced array and the second entity field enhanced array are respectively acquired to obtain the first entity field value and the second entity field value; the first entity field value and the second entity field value are stored as data to generate a field value list.

5. The method for comparing multiple data before and after based on user-defined annotations according to claim 1, characterized in that: Step S2 includes the following steps: Step S21: comparing the first entity field value and the second entity field value in the field value list one by one, and generating a first comparison result when the first entity field value is equal to the second entity field value; Step S22: When the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value.

6. The method for comparing multiple data before and after based on user-defined annotations according to claim 5, characterized in that: Comparing the first entity field value and the second entity field value in the field value list field value by field value includes: Compare the first entity field value and the second entity field value in the field value list one by one by field value type, and generate field value type data, wherein the field value type data includes a first field type, a second field type, and a third field type, wherein the first field type is a LIST type, the second field type is an OBJECT type, and the third field type is a FIELD type; The first entity field value and the second entity field value in the field value list are compared field by field value through the first field type, the second field type and the third field type, and when the first entity field value is equal to the second entity field value, a first comparison result is generated.

7. The method for comparing multiple data before and after based on user-defined annotations according to claim 6, characterized in that: Comparing the first entity field value and the second entity field value in the field value list one by one by using the first field type includes the following steps: The length of the first entity field value and the second entity field value in the field value list is judged by the first field type. If the length of the first entity field value in the field value list is equal to the length of the second entity field value, the second field type and the third field type are judged for the first entity field value and the second entity field value. If the length of the first entity field value in the field value list is equal to the length of the second entity field value, a length difference comparison is performed on the first entity field value that is equal to the second entity field value to generate a first comparison result.

8. The method for comparing multiple data before and after based on user-defined annotations according to claim 7, characterized in that: Comparing the first entity field value and the second entity field value in the field value list one by one through the second field type includes: A recursive field difference judgment is performed on the first entity field value and the second entity field value in the field value list through the second field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

9. The method for comparing multiple data before and after based on user-defined annotations according to claim 7, characterized in that: Comparing the first entity field value and the second entity field value in the field value list one by one through the third field type includes: The first entity field value and the second entity field value in the field value list are identified by using the third field type. If the first entity field value in the field value list is equal to the second entity field value, a difference comparison is performed on the first entity field value and the second entity field value to generate a first comparison result.

10. A device for comparing multiple data before and after based on custom annotations, characterized in that: For executing the method for comparing multiple data before and after based on user-defined annotations as claimed in claim 1, the device for comparing multiple data before and after based on user-defined annotations comprises: A field extraction module is used to create a HashMap data structure; obtain a first entity object and a second entity object; extract field information from the first entity object and the second entity object to obtain a temporary field list; extract field values ​​from the temporary field list through a preset annotation class to obtain a field value list; A data comparison module is used to compare the first entity field value and the second entity field value in the field value list one by one, and when the first entity field value is equal to the second entity field value, a first comparison result is generated; when the first entity field value is not equal to the second entity field value, a second comparison result is generated based on the value difference that the first entity field value is not equal to the second entity field value; The result display module is used to return the first comparison result and the second comparison result to the HashMap data structure for result return to obtain the final comparison result.