apex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chinmay Kolhatkar <chin...@datatorrent.com>
Subject Ability to generate POJO class on the fly
Date Thu, 21 Jan 2016 17:46:29 GMT
Hi All,

We're planning to add a utility in malhar-library for generating a POJO
class on the fly from given JSON schema.

Use case is where the application is provided with schema and that needs to
be used in one or more operators either as a tuple over the stream OR for

General Design:
1. Utility will be provided with fqcn of the class and schema definition
provided as json.
2. The schema definition will look like following:
       "fqcn":"<qualified class name>",
       "fields": [
           "type": "string"
3. Supported types identified in "type" JSON field are:
      boolean, char, byte, short, int, float, long, double
4. The output of this utility will be a generated .class file in the form
of FSDataOutputStream.
5. Xbean asm5 library will be used for this.
6. Following methods will be added to the generated class:
    a. Getter/Setter methods for given fields.
    b. simple toString - Generate string equivalent for all the fields
    c. hashCode method - calculate the overall hashCode using individual
field hashcodes, similar to how String.hashCode generates hashCode of
string using chars in it.
    d. equals method - Similar to how String.equals method has done it
using individual char.

Questions I have about the functionality:
1. Should the utility also support nested pojo definition via schema json?
    In such case the field definition can look like following:
    { "name":"nestedField", "type":"<fqcn of nested class>",
"fields":[....] }
    The nested class will be provided

2. Should the utility also support giving out the JarOutputStream which
will have a generated jar?

Please let me know your thoughts.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message