Java Implementation and Usage
This part is about the usage of Elastic Objects in a native java application.
Like a Java 8 Optional it contains an object. But it knows
- the EO wrapper of the parent object,
- all EO wrappers for the child objects by fieldName and
- its type rules(Model configuration).
The following classes are provided for this.
Create a new root
This cache will be usually initialized one time as static or as a (injected) singelton.
It could be also initialized with an object.
A JSON string will automatically resolved to a map or list object.
A typed JSON string will automatically mapped to the object.
Instantiating an EoRoot object use always the configration cache object. This objects loads every file named
To hide the differences between different tree type objects model configurations are loaded and provided in a cache object.
The model configurations build the base for all object access in EO.
The cache object
With the set method one could add childs also via a path pattern
The return value of set method is the child on path "a/b/c". The last test will get the map from the root and then navigate through the map tree.
Path as Array
One can also set the path in an array in java context, which simplify usage there.
With a leading "/" the path will interpreted starting with the root similar than in a file system.
One can also set an object to an arbitrary path, where the complete object tree will be mapped.
One can also set AnObject via path directive.
One could navigate through the object hierarchy in several ways with the getEo method.
Similar to a file system command there is also a back navigation with "..".
A short form for getting the value instead of the combination getEo(<path>).get() is get(<path>).
- Compare: An example to compare an object and a map for equal values.
- Transform: An example to transform an object to a map.
- Merge: An example to merge map values into an object.
Usage as a tool
With about 270 KByte Elastic Objects is rather small. So it could be integrated as a tool in java applications where it's appropriated. Other tool libraries like guava have more than 2MByte.