Super-POJO Generator

The super-POJO generator is essential for maintaining consistent business logic across different versions of the same Open API interface.

Description

The shared code includes:

  • A command interface super-POJO generator (in version 20241101, it is only compatible with Java 8)
  • A library that implements a version of the mapper to translate super-POJOs to POJOs and vice versa.

Code description

  • The super-POJOs generator:
    • This tool utilizes reflection to retrieve the attributes of Plain Old Java Objects (POJOs)
    • It offers a variety of generation options, including:
      • Customizable regular expressions to identify getters and setters
      • Add toString
      • Include hashcode and equals
      • Add builder-style
      • Create element adders for lists
      • ...
    • The jcodemodel library is used to generate the code
  • The mapping library:
    • Utilizes reflection to identify the attributes that need translation
    • Employs a cache to avoid repeating the reflection inspection multiple times
    • Permits the addition of manual translators to the mapper
    • Provides recursive translation of each parameter from one POJO to another

The reflection translation process is slow, and if there are many requests, it can create a bottleneck.

Based on my tests, which involved handling several hundred requests per second, the execution tends to stall during the first few seconds.

After that initial period, the execution becomes significantly faster.

There are a few reasons why this might occur:

  • At first, the cache is not populated.
  • After some time, the JVM optimizer (JIT, Just-In-Time) activates, translating the most frequently used code into highly optimized machine code.

Try warming up the execution before opening the listening ports to avoid a lag time at the beginning.

Windows

All

Super-POJO Generator (2024)

Download

Versions

image

The super pojo generator was born from the need to unify different versions of pojo models, in order to try to offer a common logic to all versions.

You can see more details about the application and the associated library in the superpojo-model project on github

Downloads