Package dev.javatools.maputils
Class MapUpdate
java.lang.Object
dev.javatools.maputils.MapUpdate
public class MapUpdate
extends java.lang.Object
You can add, update, delete any element in the map by specifying the path in the following format.
Example 1:
person.address.zip - will perform operations on the element at that location in the map.
Map
person: address
address : zip
zip : <value> -- Performs the operation this field
Example 2:
person.address[2].zip - will perform operations on the element at that location in the map.
Map
person: address[]
address[1]: .....
address[2] : zip
zip : <value> -- Performs the operation this field
-
Constructor Details
-
MapUpdate
public MapUpdate()
-
-
Method Details
-
set
public static void set(java.lang.String mapPath, java.util.Map sourceMap, java.lang.Object value)Possible values for destination path 1. name - field at the root level 2. primaryAddress.street - field in an inner object 3. associatedAddresses[] - add an (any)object to a list, object will be added at the end of the list 4. associatedAddresses[1] - will add associated object at location 1 in the list, if there is an object that is already existing at that location in that list, then it will be overwritten} 5. associatedAddresses[{state=CA}].street street - address will be updated with the value where associatedAddresses state is california 5. associatedAddresses[{state:CA}, {zip:94599}].street - street address will be updated with the value where associatedAddresses state is california and zip is 94599 6. friends[{name=Art Venere}].age - updates the age of a friend whos name is "Art Venere" 7. friends[{name=Art Venere}].primaryAddress.street 8. friends[{name=Art Venere}].associatedAddresses[] {associated address of the friend should be added at the end of the list, if exists, override} 9. friends[{name=Art Venere}].associatedAddresses[{state=CA}].street 10. friends[{name=Art Venere}].associatedAddresses[{state=CA},{city:Irving}].street Current implementation will assume that the map has 1. map or 2. list or any terminal object (String/Integer/..) as the value for any given key. Current implementation does not support Set or custom objects in the Map for this operation.- Parameters:
mapPath- Path in the MapsourceMap- the map that needs to be updatedvalue- the alue that needs to be updated with in the path specified.
-