Map parameter access processing method, system and device and storage medium

By defining object attribute annotations and custom tool classes, automatic access to Map parameters is realized, which solves the shortcomings in null value verification, type conversion and function calculation in the existing technology, and improves the flexibility and robustness of parameter reading and storage.

CN120085909APending Publication Date: 2025-06-03SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510141021.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-08
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

The existing Map parameter reading storage method is difficult to meet complex and changeable business needs, especially in terms of null value verification, parameter type conversion and function calculation.

Method used

By defining object attribute annotations, a mapping relationship between object attributes and Map parameters is established, and object attribute annotations are read through custom tool classes to realize automatic access to Map parameters, supporting null value verification, parameter type conversion and function calculation.

Benefits of technology

Automatic access to Map parameters is realized, the security and scalability of parameter read storage is improved, duplicate development is reduced, and the iterative efficiency of development is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120085909A_ABST
    Figure CN120085909A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, and particularly provides a Map parameter access processing method, system and device and a storage medium, and the method comprises the steps: building a mapping relation between an object attribute and a Map parameter through defining an object attribute annotation; configuring the object attribute annotation to an object file; and reading the object attribute annotation through a self-defined tool class according to a business logic requirement of an object file, and accessing the Map parameter based on the object attribute annotation. According to the invention, the security and expansibility of Map parameter reading and storage are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and particularly relates to a method, system, device and storage medium for Map parameter access and processing. Background Art

[0002] In the current field of computer back-end development, the Java language has become the first choice of many developers due to its powerful functions and wide application scenarios. In the Java class library system, Map, as a commonly used collection class, occupies a crucial position. Map stores data in the form of key-value pairs, and this unique data structure enables it to efficiently store, retrieve and manage data. In actual project development, Map is widely used in various scenarios. For example, when processing configuration files, Map can conveniently store configuration items and their corresponding values; when encapsulating database query results, Map can use field names as keys and field values as values, thus clearly presenting the data.

[0003] Currently, in the computer back-end field, Map is frequently used as a data passing parameter method for interfaces and methods. This is mainly because Map has a high degree of flexibility and can easily adapt to different types of data passing requirements. Whether it is the passing of simple strings and numerical values or the transmission of complex custom objects, Map can handle them. By encapsulating relevant data in Map, developers can conveniently pass data between different modules, achieve decoupling between modules, and improve the maintainability and extensibility of the code.

[0004] However, although Map has many advantages in data passing parameters, the existing parameter reading and storage methods have certain limitations and are difficult to meet the increasingly diverse parameter reading and storage scenarios. In actual projects, developers often encounter various complex requirements. For example, in some business scenarios, it is necessary to strictly verify the null values of the parameters in Map to ensure the integrity and accuracy of the data. However, the existing reading and storage methods may not directly provide a convenient null value verification mechanism, and developers need to manually write a large amount of code for judgment, which not only increases the redundancy of the code but also easily introduces errors.

[0005] Another example is in parameter type conversion. When reading data from Map and assigning it to a target object, it may be necessary to convert the data type in Map to the specific type required by the target object. However, the existing methods may not be able to automatically complete this type conversion, or lack flexibility and robustness during the type conversion process, resulting in the need to write a large amount of conditional judgment and conversion logic when processing different types of data.

[0006] In addition, for requirements such as parameter default value setting and parameter function calculation, the existing Map parameter reading and storage methods are also inadequate. In some cases, when a certain key parameter is missing in the Map, a default value needs to be set for it to ensure the normal operation of the business; in other scenarios, complex function calculations may need to be performed on multiple parameters in the Map to obtain the final result. However, the existing methods often cannot directly meet these requirements, and developers have to spend a lot of time and energy to implement these functions.

[0007] In summary, although Map is widely used as a data passing parameter method in the computer backend field, it cannot adapt to complex and changing business requirements. Summary of the Invention

[0008] In view of the above deficiencies of the prior art, the present invention provides a Map parameter access and processing method, system, device and storage medium to solve the above technical problems.

[0009] In a first aspect, the present invention provides a Map parameter access and processing method, including: Establish a mapping relationship between object attributes and Map parameters by defining object attribute annotations; Configure the object attribute annotations into the object file; According to the business logic requirements of the object file, read the object attribute annotations through a custom tool class, and access the Map parameters based on the object attribute annotations.

[0010] In an optional implementation manner, the object attribute annotations include: Define key[String], used to mark the key value of the Map; Define input[Boolean], used to mark that the object attribute reads parameters from the Map; Define output[Boolean], used to mark that the object attribute stores data into the Map; Define notEmpty[Boolean], used to mark whether the object attribute can be a null value, perform null value verification when reading Map parameters, and throw an exception prompt if the object attribute is null; perform null value verification when storing Map parameters, and throw an exception prompt if the object attribute is null; Define inputClass[Class], used to mark the type that needs to be converted when the object attribute reads from the Map; Define outputClass[Class], used to mark the type that needs to be converted when the object attribute is stored into the Map; Define defaultVal[Object], which is the default value set when reading or storing null in the Map; Define function[Function], which is used to identify the processing result. The processing result is used to set to the object property, and the processing result is the value obtained by reading multiple keys from the Map and performing calculations.

[0011] In an optional embodiment, by defining an object property annotation, a mapping relationship between the object property and the Map parameter is established, including: In the standard directory structure of the Java project, create a source file directory for storing the object property annotation; Save the object property annotation to the source file directory.

[0012] In an optional embodiment, configure the object property annotation to the object file, including: Use the project management tool to import the object property annotation; Configure the reference permission of the object file to the object property annotation.

[0013] In an optional embodiment, the tool class includes: Define a parameter reading tool for reading parameters from the Map into the object property; Define a parameter storage tool for reading data from the object property and storing it in the Map; The parameter reading tool includes: Use Java reflection to read the object property annotation of the object file; according to the input property of the object property annotation, filter the target object properties that need to read parameters from the Map; Read the target parameter with the corresponding key value from the Map according to the key value of the object property annotation, perform null value verification on the read target parameter according to notEmpty, convert the target parameter into the corresponding data type according to inputClass, and perform function calculation on the read multiple target parameters according to function; Use Java reflection to set the parameters read from the Map to the object property; The parameter storage tool includes: Use Java reflection to read the object property annotation of the object file; according to the output property of the object property annotation, filter the target object properties that need to be stored in the Map; Read the property value of the target object using reflection. According to the key value of the object property annotation, store the property value of the target object in the parameter item with the corresponding key value in the Map. Perform null value verification based on notEmpty, and convert the property value of the target object into the corresponding data type according to outputClass.

[0014] In an optional implementation, according to the business logic requirements of the object file, read the object property annotation through a custom utility class and access the Map parameter based on the object property annotation, including: At the business logic entry of the object file, use a parameter reading tool to read parameters from the Map; At the business logic exit of the object file, use a parameter storage tool to store the value of the target object property into the Map.

[0015] In a second aspect, the present invention provides a Map parameter access and storage processing system, including: An annotation definition module, used to establish a mapping relationship between object properties and Map parameters by defining object property annotations; An annotation configuration module, used to configure the object property annotation to the object file; An access and execution module, used to read the object property annotation through a custom utility class according to the business logic requirements of the object file and access the Map parameter based on the object property annotation.

[0016] In an optional implementation, the object property annotation includes: Define key[String], used to mark the key value of the Map; Define input[Boolean], used to mark that the object property reads parameters from the Map; Define output[Boolean], used to mark that the object property stores data into the Map; Define notEmpty[Boolean], used to mark whether the object property can be a null value. Perform null value verification when reading Map parameters. If the object property is null, throw an exception prompt; perform null value verification when storing Map parameters. If the object property is null, throw an exception prompt; Define inputClass[Class], used to mark the type that needs to be converted when the object property reads from the Map; Define outputClass[Class], used to mark the type that needs to be converted when the object property stores into the Map; Define defaultVal[Object], the default value set when reading or storing the Map as null; Define a function [Function] to identify the processing result, which is used to set into the object property. The processing result is a value obtained by reading multiple keys from the Map and performing calculations.

[0017] In a third aspect, a device is provided, including: A memory for storing a Map parameter access and processing program; A processor for implementing the steps of the Map parameter access and processing method provided in the first aspect when executing the Map parameter access and processing program.

[0018] In a fourth aspect, a computer-readable storage medium is provided, on which a Map parameter access and processing program is stored. When the Map parameter access and processing program is executed by a processor, the steps of the Map parameter access and processing method provided in the first aspect are implemented.

[0019] The beneficial effects of the present invention are as follows. The Map parameter access and processing method, system, device and storage medium provided by the present invention realize the automatic access of Map parameters through custom annotations and utility classes, can adapt to requirements such as null value verification, parameter type conversion and function calculation, improve the security and scalability of Map parameter reading and storage, avoid repeated development of Map parameter reading and storage, and improve the iteration efficiency of development.

[0020] In addition, the design principle of the present invention is reliable, the structure is simple, and it has a very wide application prospect. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can also be obtained based on these drawings without creative efforts.

[0022] Figure 1 is a schematic flowchart of the method according to an embodiment of the present invention.

[0023] Figure 2 is a schematic block diagram of the system according to an embodiment of the present invention.

[0024] Figure 3 is a schematic structural diagram of a device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0025] To enable those skilled in the art to better understand the technical solutions in the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0026] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terms used in the description of the present invention in this specification are only for the purpose of describing specific embodiments, and are not intended to limit the present invention.

[0027] The following explains the key terms that appear in the present invention.

[0028] Meaning of "object": The object here refers to an instance object in Java programming, which is a specific instance of a class. Each object has its own attributes and methods for encapsulating data and behaviors. For example, assuming there is a User class, the user created by User user = new User(); is an object, which may contain attributes such as name and age and related operation methods.

[0029] Relationship between object and Map parameter: Map parameter as the source of object attribute values: Through the @MapperKey annotation configuration, the attribute values of an object can be read from the Map parameter. For example, for a certain attribute address of an object, it can be marked with the @MapperKey annotation and read from the value in the Map corresponding to the key "address", filling the data in the Map into the attributes of the object to achieve the initialization of the object attributes.

[0030] Object attribute values stored into Map parameter: Similarly through the @MapperKey annotation, the attribute values of an object can be stored into the Map. When it is necessary to transfer, store, or process certain attribute values of an object as a whole, these attribute values can be stored into the Map according to the annotation configuration for subsequent operations. For example, when returning the result of a method, the relevant attribute values of the object are stored into the Map and returned to the calling party.

[0031] Establishing associations through annotations: The @MapperKey annotation serves as a bridge between an object and a Map parameter. Through various property configurations of this annotation (such as key, input, output, etc.), the mapping relationship, reading and storage directions, null value verification, and other rules between object properties and Map parameters are clarified, enabling the object and the Map parameter to interact according to the developer's requirements.

[0032] In business logic methods, Map parameters are often used to pass a set of related data between different modules or methods. It provides a flexible way to process and exchange data, especially when the data structure is not fixed or needs to be dynamically adjusted. Map can conveniently meet this requirement. For example, in a Web application, the parameters passed from the front end may be encapsulated into a Map, and the back end receives and converts them into corresponding object property values in this way, or converts the object property values into a Map and returns it to the front end.

[0033] The Map parameter access and storage processing method provided by the embodiments of the present invention is executed by a computer device. Correspondingly, the Map parameter access and storage processing system runs in the computer device.

[0034] Figure 1 It is a schematic flowchart of the method of an embodiment of the present invention. Among them, Figure 1 The execution subject can be a Map parameter access and storage processing system. According to different requirements, the order of the steps in this flowchart can be changed, and some can be omitted.

[0035] As Figure 1 shown, the method includes: S1, establish the mapping relationship between object properties and Map parameters by defining object property annotations.

[0036] Deeply analyze the business requirements and clarify the corresponding rules between object properties and Map parameters. For example, in a user information management system, the User object may contain properties such as name, age, and email. When interacting with the front end or passing data to other modules, this information may exist in the form of a Map parameter. At this time, an annotation needs to be defined, such as @MapPropertyMapping.

[0037] In the @MapPropertyMapping annotation, various properties are defined in detail to precisely describe the mapping relationship. For example, the key property is used to specify the corresponding key name in the Map in the @MapPropertyMapping annotation, so as to clearly indicate the correspondence between the object property and a specific key-value pair in the Map. At the same time, the input and output properties are set, which are used to mark whether the property reads data from the Map (input is true) or stores the object property value into the Map (output is true), respectively. To ensure data integrity and accuracy, the notEmpty property can also be defined to mark whether the object property allows null values. In addition, for the case where data types may be inconsistent, the inputClass and outputClass properties are set to specify the type conversions required when reading data from the Map and storing data into the Map, respectively. If some special calculations or processing need to be performed on the Map parameters, the function property can also be added to define the corresponding calculation logic. S2, configure the object property annotation into the object file.

[0038] Apply the defined mapping rules to the actual object to ensure that the object follows the established rules when interacting with the Map parameters.

[0039] Taking the User object as an example, in its definition file, for each property that needs to interact with the Map parameters, add the corresponding @MapPropertyMapping annotation.

[0040] The mapping relationship between the object property and the Map parameters is intuitively reflected in the object file. The annotation on each property clearly shows the specific rules for this property when interacting with the Map for data, whether it is reading data from the Map or storing data into the Map, there are clear guidelines.

[0041] S3, according to the business logic requirements of the object file, through a custom tool class, read the object property annotation and access the Map parameters based on the object property annotation.

[0042] After configuring the object property annotation into the object file, to implement the data access and storage operations between the object and the Map parameters, create a custom tool class. This tool class is like a smart bridge builder that can accurately read the annotation information on the object property according to the business logic requirements of the object file and implement the access and storage operations of the Map parameters based on this information.

[0043] First, create a tool class named ObjectMapUtils. In this tool class, define two core methods: toMapInput and toMapOutput.

[0044] The main responsibility of the toMapInput method is to read data from the Map parameter and assign it to the corresponding properties of the object according to the annotation information.

[0045] In this method, first obtain the class information of the object and all declared fields. Then iterate through these fields, check if each field has the @MapPropertyMapping annotation and the input property is true. If the conditions are met, obtain the corresponding key-value from the Map. Next, perform a null value check based on the notEmpty property. If type conversion is required, determine the target type according to the inputClass property and call the convertValue method for conversion. Finally, set the converted value to the property of the object.

[0046] The toMapOutput method is responsible for storing the property values of the object into the Map.

[0047] In this method, also iterate through all the fields of the object, check the fields with the @MapPropertyMapping annotation and the output property being true. After obtaining the value of the field, perform a null value check and type conversion (if required), and finally store the value under the corresponding key in the Map.

[0048] In an embodiment of the present invention, based on step S1, a possible embodiment will be given below to non-restrictively elaborate on its specific implementation.

[0049] In the src / main / com / mapper / annotation directory, add the @MapperKey annotation to define the functional configuration for reading and storing Map parameters.

[0050] The @MapperKey annotation is an object property annotation, which specifically includes the following content: Define key[String], which is used to mark the key value of the Map; during the process of the object reading and storing Map parameters, the key property of the @MapperKey annotation configured for the object property is read through the Java reflection mechanism to read and store the corresponding parameters from the Map.

[0051] Define input[Boolean], which is used to mark that the object property reads parameters from the Map; read data from the Map through map.get(key) and use the Java reflection method field.set(obj) to set it to the object property.

[0052] Define output[Boolean], which is used to mark that the object property stores data into the Map; read data from the object through the Java reflection method field.invoke(object), and use the Map method map.put(key, obj) to store it into the corresponding key.

[0053] Define notEmpty[Boolean], which is used to mark whether the object property can be a null value. When reading the Map parameter, Object res = map.get(obj), and check for null value of res, res == null. If it is null, throw an IllegalArgumentException; when storing the Map parameter, check the object property Object res = field.invoke(object) read by Java reflection, res == null. If it is null, throw an IllegalArgumentException.

[0054] Define inputClass[Class], which is used to mark the type to be converted when reading the object property from the Map; Define outputClass[Class], which is used to mark the type to be converted when storing the object property into the Map; Define defaultVal[Object], which is the default value set when reading or storing the Map as null; Define function[Function], which is used to identify the processing result. The processing result is used to set to the object property, and the processing result is the value obtained by reading multiple keys from the Map and performing calculations.

[0055] In an embodiment of the present invention, based on step S2, a possible embodiment will be given below to non - restrictively elaborate on its specific implementation.

[0056] Import object property annotations using a project management tool; configure the reference permissions of the object file for the object property annotations.

[0057] Specifically, use Maven to import the dependency package containing object property annotations and utility classes. Then, when using, in the Java object file, reference the import com.mapper.annotation.@MapperKey annotation, and the annotation configuration can be performed on the object property.

[0058] In an embodiment of the present invention, based on step S3, a possible embodiment will be given below to non - restrictively elaborate on its specific implementation scheme.

[0059] Under the directory src / main / com / mapper / utils, add the ObjectMapperUtils class, which is used to read the object property annotation @MapperKey using Java reflection and read and store the parameters of the Map.

[0060] The ObjectMapperUtils class is a utility class, including: (1) Define the parameter reading tool toInputAttrs(Object object, Map<String, Object> mapper), which is used to read parameters from the Map into object properties; Use Java reflection to read the object property annotations of the object file; according to the input property of the object property annotation, filter the target object properties that need to read parameters from the Map; Read the target parameters with corresponding key values in the Map according to the key value of the object property annotation, perform null value verification on the read target parameters according to notEmpty, convert the target parameters into the corresponding data types according to inputClass, and perform function calculations on the multiple read target parameters according to function; Use Java reflection to set the parameters read from the Map into the object properties.

[0061] Among them, the method for controlling verification according to notEmpty includes: Obtain the @MapperKey annotation on the object property: Use Java reflection to obtain all the property fields of the object, and then obtain its @MapperKey annotation for each field.

[0062] Check the input property: Judge whether the input property in the annotation is true. If it is, it means that this property needs to read data from the Map.

[0063] Obtain the corresponding value from the Map: According to the key property in the annotation, obtain the corresponding value from the Map.

[0064] Null value verification: Check whether the notEmpty property is true. If it is, then check whether the value obtained from the Map is null. If it is null, throw an IllegalArgumentException exception.

[0065] Subsequent processing: If the value is not null or notEmpty is false, continue with subsequent type conversions and other processing, and set the value to the object property.

[0066] Data type conversion methods include: Obtain object properties and @MapperKey annotations: Use Java reflection to obtain all property fields of the object, and for each field, obtain its @MapperKey annotation.

[0067] Check the input property: Determine whether the input property in the annotation is true. If so, it means that this property needs to read data from the Map.

[0068] Obtain the corresponding value from the Map: According to the key property in the annotation, obtain the corresponding value from the Map.

[0069] Check inputClass: Determine whether inputClass is void.class (the default value). If not, it means that type conversion is required.

[0070] Perform type conversion: According to the type of inputClass, use the corresponding conversion logic to convert the value obtained from the Map into the target type.

[0071] Set the property value: Set the converted value to the property of the object.

[0072] Function calculation methods include: Obtain object properties and @MapperKey annotations: Use Java reflection to obtain all property fields of the object, and for each field, obtain its @MapperKey annotation.

[0073] Check the input property: Determine whether the input property in the annotation is true. If so, it means that this property needs to read data from the Map.

[0074] Check the function property: Determine whether the function property is empty (in the actual implementation, it can be judged in an appropriate way, such as whether it is the default value or null). If it is not empty, it means that function calculation is required.

[0075] Read the required parameters from the Map: According to the logic defined by the function, determine which keys in the Map need to be read as the parameters of the function.

[0076] Execute function calculation: Use the function configured by function to calculate the read parameters. The function here can be a custom Lambda expression, method reference, or other object that implements specific calculation logic.

[0077] Set property value: Set the calculation result into the properties of the object.

[0078] (2) Define the parameter storage tool toOutputAttrs(Object object, Map<String, Object> mapper) to read data from object properties and store it in a Map; Use Java reflection to read the object property annotations of the object file; Filter the target object properties to be stored in the Map according to the output property of the object property annotation; Use reflection to read the property values of the target object properties, and store the property values of the target object properties in the parameter items with the corresponding key values in the Map according to the key value of the object property annotation. Perform null value verification according to notEmpty, and convert the property values of the target object properties into the corresponding data types according to outputClass.

[0079] Java's reflection mechanism allows obtaining class information at runtime, including class properties, methods, constructors, etc. In this scenario, first use reflection to read the annotations on each object property in the object file.

[0080] Obtain the class information of the target object. The class instance can be obtained through the getClass() method of the Class class or the Class.forName() method. For example, assume there is a User class and an instance user of the User class: User user = new User(); Class<>clazz = user.getClass().

[0081] Next, obtain all the declared fields (i.e., properties) of this class. An array containing all the declared fields can be obtained through the clazz.getDeclaredFields() method. Then, traverse this array, and for each field, use the field.getAnnotation() method to obtain the @MapperKey annotation on it (assuming the custom annotation name is @MapperKey).

[0082] Field[] fields = clazz.getDeclaredFields(); for (Field field : fields) { MapperKey annotation = field.getAnnotation(MapperKey.class); if (annotation != null) { / / Subsequent operations are performed according to the annotation}}。

[0083] After obtaining the annotation of each attribute, determine whether the attribute needs to be stored in the Map according to the output attribute in the annotation. The output attribute is a boolean value. When it is true, it means that the attribute needs to be stored.

[0084] In the above loop for traversing fields, add a judgment on the output attribute: for (Field field : fields) { MapperKey annotation = field.getAnnotation(MapperKey.class); if (annotation != null && annotation.output()) { / / This attribute needs to be stored in the Map and is marked as an attribute of the target object / / Subsequent storage operations are performed}}。

[0085] For the target object attributes that are screened out and need to be stored in the Map, use reflection to obtain their attribute values. Since these attributes may be private, set the accessibility of the field through the field.setAccessible(true) method.

[0086] Then, use the field.get(object) method to obtain the value of the target object attribute. Here, object is the specific object instance to be operated on. Continue to perform the following steps: For each Field object field in fields: Obtain the MapperKey annotation on field and assign it to a variable annotation of type MapperKey. If annotation is not null and the output attribute of annotation is true: Try to perform the following operations: Set field to be accessible (even if it is private). Obtain the property value corresponding to field from the user object and assign it to a variable value of type Object. If an IllegalAccessException (illegal access exception) is caught during the execution: Print the stack trace information of the exception (for debugging and locating problems).

[0087] The value of the target object's property has been obtained. Next, according to the key value in the annotation, this value needs to be stored in the corresponding parameter item in the Map. For example, a variable mapper of type Map<String, Object> is known and is used to store property values. After obtaining the property value, perform the following operations: / / Create a HashMap instance to store key-value pairs, where the type of the key is String and the type of the value is Object Map<String, Object> mapper = new HashMap<>(); / / Traverse all declared fields of the class for (Field field : fields) { / / Obtain the MapperKey annotation on the field MapperKey annotation = field.getAnnotation(MapperKey.class); / / If the annotation exists and the output attribute is true if (annotation!= null && annotation.output()) { try { / / Set the field to be accessible, even if it is private field.setAccessible(true); / / Obtain the value of this field in the object user Object value = field.get(user); / / Obtain the key defined in the annotation String key = annotation.key(); / / Put the key-value pair into mapper mapper.put(key, value);} catch (IllegalAccessException e) { / / If an illegal access exception occurs, print the exception stack information e.printStackTrace();}}}。

[0088] Before storing the attribute value into the Map, it is necessary to perform a null value check based on the notEmpty attribute. The notEmpty attribute is also a boolean value in the @MapperKey annotation. When it is true, it means that the attribute value is not allowed to be null. If it is null, an IllegalArgumentException exception is thrown to prompt the caller that there is a problem with the data.

[0089] Perform type conversion on the attribute value according to the outputClass attribute. The outputClass attribute specifies the data type to be stored in the Map. Define a method to perform type conversion, such as the convertValueToOutput method, and then call this method for conversion before storing the value.

[0090] After completing the definition of the utility class, perform Map parameter access and storage: S301. At the entrance of the business logic method, use ObjectMapperUtils.toInputAttrs to read parameters from the Map.

[0091] When the business logic method starts to execute, it is usually necessary to receive data from the outside as input. These input data may be passed in the form of a Map, containing various parameters required for business processing. At this time, using the toInputAttrs method of the ObjectMapperUtils utility class can accurately read the parameters in the Map and assign them to the corresponding object attributes, preparing for subsequent business logic processing.

[0092] The processUserInfo method is a business logic method for processing user information. It receives a parameter userInfoMap of type Map. Inside the method, first a User object is created, and then the ObjectMapperUtils.toInputAttrs method is called to read the parameters in userInfoMap and set them to the corresponding attributes of the user object. In this way, in subsequent business logic processing, the attribute values of the user object can be directly used for operations.

[0093] S302. At the exit of the business logic method, use ObjectMapperUtils.toOutputAttrs to store the parameters into the Map.

[0094] After the business logic method is executed, it is usually necessary to return the processing result to the caller in some form. In many cases, the result data is encapsulated into a Map for easy transfer and use between different modules. At this time, using the toOutputAttrs method of the ObjectMapperUtils utility class can accurately store the attribute values of the object into the Map to complete the data output operation.

[0095] In some embodiments, the Map parameter access and processing system may include multiple functional modules composed of computer program segments. The computer programs of each program segment in the Map parameter access and processing system can be stored in the memory of the computer device and executed by at least one processor to perform the functions of Map parameter access and processing (see Figure 1 description).

[0096] In this embodiment, according to the functions it performs, the Map parameter access and processing system can be divided into multiple functional modules, as Figure 2 shown. The functional modules of the system may include: an annotation definition module, an annotation configuration module, and an access execution module. The module referred to in the present invention refers to a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.

[0097] The annotation definition module is used to establish a mapping relationship between object attributes and Map parameters by defining object attribute annotations; The annotation configuration module is used to configure the object attribute annotations into the object file; The access execution module is used to read the object attribute annotations through a custom utility class according to the business logic requirements of the object file, and access the Map parameters based on the object attribute annotations.

[0098] Optionally, as an embodiment of the present invention, the object attribute annotations include: Define key [String], which is used to mark the key value of the Map; Define input [Boolean], which is used to mark that the object attribute reads parameters from the Map; Define output [Boolean], which is used to mark that the object attribute stores data into the Map; Define notEmpty [Boolean], which is used to mark whether the object attribute can be a null value. During Map parameter reading, null value checking is performed. If the object attribute is null, an exception prompt is thrown; during Map parameter storage, null value checking is performed. If the object attribute is null, an exception prompt is thrown; Define inputClass[Class], which is used to mark the type that needs to be converted when reading object attributes from a Map; Define outputClass[Class], which is used to mark the type that needs to be converted when storing object attributes into a Map; Define defaultVal[Object], which is the default value set when reading from or storing a null value in the Map; Define function[Function], which is used to identify the processing result. The processing result is used to set into the object attribute, and the processing result is the value obtained by reading multiple keys from the Map and performing calculations.

[0099] Figure 3 The Map parameter access and processing method provided by the embodiments of the present application can be applied to a device. Those skilled in the art can understand that the device structure involved in the embodiments of the present invention does not constitute a limitation on the device. The device may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements. In the embodiments of the present invention, the device includes, but is not limited to, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The device can also represent various forms of mobile devices, such as, a personal digital processor, a cellular phone, a smart phone, a wearable device, and other similar computing devices. The components shown in the figure, their connections and relationships, and their functions are only examples and are not intended to limit the implementation of the embodiments of the present application described and / or claimed herein.

[0100] Among them, the device 300 may include: a processor 310, a memory 320, and a communication unit 330. These components communicate through one or more buses. Those skilled in the art can understand that the structure of the server shown in the figure does not constitute a limitation on the present invention. It can be a bus structure, a star structure, or may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements.

[0101] Among them, the memory 320 can be used to store the execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the device 300 can execute some or all of the steps in the above method embodiments.

[0102] The processor 310 is the control center of the storage device, connecting various parts of the entire electronic device through various interfaces and circuits. By running or executing software programs and / or modules stored in the memory 320, and by invoking data stored in the memory, it executes various functions of the electronic device and / or processes data. The processor may be composed of an integrated circuit (IC), for example, it may be composed of a single packaged IC, or it may be composed of multiple packaged ICs with the same or different functions connected together. For example, the processor 310 may include only a central processing unit (CPU). In the embodiments of the present invention, the CPU may be a single arithmetic core or may include multiple arithmetic cores.

[0103] The communication unit 330 is used to establish a communication channel so that the storage device can communicate with other devices. It receives user data sent by other devices or sends user data to other devices.

[0104] The present invention also provides a computer storage medium. Among them, the computer storage medium can store a program, and when the program is executed, it can include some or all of the steps in the embodiments provided by the present invention. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.

[0105] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be realized by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solutions in the embodiments of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., which can store program codes, and includes several instructions to enable a computer device (which may be a personal computer, a server, or a second device, a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0106] For the same or similar parts among the various embodiments in this specification, reference can be made to each other. In particular, for the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for the relevant parts, reference can be made to the descriptions in the method embodiments.

[0107] In several embodiments provided by the present invention, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of the modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the system or module can be in electrical, mechanical or other forms.

[0108] The modules described as separate components may or may not be physically separated. The components displayed as modules may or may not be physical modules, that is, they can be located in one place or distributed to multiple network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0109] In addition, in each embodiment of the present invention, the functional modules can be integrated in a processing module, or each module can exist physically alone, or two or more modules can be integrated in one module.

[0110] Although the present invention has been described in detail by referring to the accompanying drawings and in combination with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, those of ordinary skill in the art can make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions should all be within the scope of the present invention. / Any person skilled in the art within the technical scope disclosed by the present invention can easily think of changes or substitutions, and they should all be covered within the protection scope of the present invention.

Claims

1. A Map parameter access processing method, characterized in that: include: By defining object attribute annotations, a mapping relationship between object attributes and Map parameters is established; Configuring the object attribute annotation to the object file; According to the business logic requirements of the object file, the object attribute annotation is read through a custom tool class, and the Map parameters are accessed based on the object attribute annotation.

2. The method according to claim 1, characterized in that The object attribute annotations include: Define key[String] to mark the key value of Map; Define input[Boolean] to mark object attributes to read parameters from Map; Define output[Boolean] to mark object attributes to store data in Map; Define notEmpty[Boolean] to mark whether an object property can be null. Perform a null value check when reading Map parameters. If the object property is null, an exception is thrown. Perform a null value check when storing Map parameters. If the object property is null, an exception is thrown. Define inputClass[Class] to mark the type that needs to be converted when object attributes are read from Map; Define outputClass[Class] to mark the type that needs to be converted when object attributes are stored in Map; Define defaultVal[Object], which is the default value set when the Map is read or stored as null; Define function[Function] to identify the processing result, which is used to set the object attribute. The processing result is the value obtained by reading multiple keys from the Map and calculating them.

3. The method according to claim 2, characterized in that By defining object attribute annotations, a mapping relationship between object attributes and Map parameters is established, including: In the standard directory structure of the Java project, create a source file directory for storing the object attribute annotations; The object attribute annotation is saved to the source file directory.

4. The method according to claim 1, characterized in that: Configure the object attribute annotation to the object file, including: Import object attribute annotations using project management tools; Configure the object file's reference permissions to the object attribute annotations.

5. The method according to claim 1, characterized in that The tools include: Define parameter reading tools to read parameters from Map into object attributes; Define parameter storage tools to read data from object attributes and store them in Map; The parameter reading tool comprises: Use Java reflection to read the object attribute annotation of the object file; according to the input attribute of the object attribute annotation, filter the target object attribute that needs to read the parameter from the Map; Read the target parameter with the corresponding key value of the target object attribute from the Map according to the key value annotated by the object attribute, perform null value check on the read target parameter according to notEmpty, convert the target parameter into the corresponding data type according to inputClass, and perform function calculation on the read multiple target parameters according to function; Use Java reflection to set the parameters read from the Map to the object properties; The parameter storage tool comprises: Use Java reflection to read the object attribute annotation of the object file; filter the target object attributes that need to be stored in the Map according to the output attribute of the object attribute annotation; Use reflection to read the attribute value of the target object attribute, store the attribute value of the target object attribute in the parameter item with the corresponding key value in the Map according to the key value annotated by the object attribute, perform null value check according to notEmpty, and convert the attribute value of the target object attribute into the corresponding data type according to outputClass.

6. The method according to claim 5, characterized in that According to the business logic requirements of the object file, the object attribute annotation is read through a custom tool class, and the Map parameters are accessed based on the object attribute annotation, including: At the business logic entry of the object file, use the parameter reading tool to read parameters from the Map; At the business logic exit of the object file, use the parameter storage tool to store the value of the target object attribute into the Map.

7. A Map parameter access processing system, characterized in that: include: Annotation definition module, used to establish the mapping relationship between object attributes and Map parameters by defining object attribute annotations; An annotation configuration module, used for configuring the object attribute annotation to the object file; The access execution module is used to read the object attribute annotation according to the business logic requirements of the object file through a custom tool class, and access the Map parameter based on the object attribute annotation.

8. The system according to claim 7, characterized in that The object attribute annotations include: Define key[String] to mark the key value of Map; Define input[Boolean] to mark object attributes to read parameters from Map; Define output[Boolean] to mark object attributes to store data in Map; Define notEmpty[Boolean] to mark whether an object property can be null. Perform a null value check when reading Map parameters. If the object property is null, an exception is thrown. Perform a null value check when storing Map parameters. If the object property is null, an exception is thrown. Define inputClass[Class] to mark the type that needs to be converted when object attributes are read from Map; Define outputClass[Class] to mark the type that needs to be converted when object attributes are stored in Map; Define defaultVal[Object], which is the default value set when the Map is read or stored as null; Define function[Function] to identify the processing result, which is used to set the object attribute. The processing result is the value obtained by reading multiple keys from the Map and calculating them.

9. A Map parameter access processing device, characterized in that: include: A memory, used for storing a Map parameter access processing program; A processor, used to implement the steps of the Map parameter access processing method as described in any one of claims 1 to 6 when executing the Map parameter access processing program.

10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores a Map parameter access processing program, and when the Map parameter access processing program is executed by a processor, the steps of the Map parameter access processing method according to any one of claims 1 to 7 are implemented.