Java Implementation and Usage

This part is about the usage of Elastic Objects in a native java application.

EO.java is a generic object wrapper skin with typed path methods to an java object skeleton. Typed objects are embedded in an untyped map structure.

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.

The following examples are in the test class EoHtmlTest.java using the test object ≡AnObject

Create a new root

The EoRoot.java is for initializing the root of the tree. It has a constructor with the cache object.

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.

Configuration Cache

Instantiating an EoRoot object use always the configration cache object. This objects loads every file named

from the classpath when initialized.

Model Configuration

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 EOConfigsCache.java loads all ModelConfig.json, Models.json and FieldConfig.json files from the classpath.

Set Values

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.

Setting Objects

One can also set an object to an arbitrary path, where the complete object tree will be mapped.

Typed Path

One can also set AnObject via path directive.

Get EO

One could navigate through the object hierarchy in several ways with the getEo method.

Back Navigation

Similar to a file system command there is also a back navigation with "..".

Get Values

A short form for getting the value instead of the combination getEo(<path>).get() is get(<path>).

Call Types

A special ≡Call bean with a generic execution method offers functionality. Its has the following important fields:

Other Examples
  • 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.

This Page Elements
Get Method: WebEoGet.java
Post Method: WebEo.java
Page-Template: ≡ContentPage.html
Header: Header.html
Content-Directory:⊚eo
Navigation: ≡eo_Nav.html
Content: EO.html
Footer: Footer.html
Postversion of this page: