Skip to content
Thomas Deutsch edited this page Jul 5, 2017 · 2 revisions

Welcome to the tcmj-pug-enums wiki!

Project Description

The tcmj pug enums project is a toolkit to create high quality java enum classes from several datasources like html pages or json data. A highlight of the project is our maven plugin which allows you to create a java enum class simply by configuration. Our killer-use-case is to have a actual version of all iso-3166 countries ready in the form of a java enum.

The Problem

In development projects you may have requirements to work with very important data which usually doesn't change very often. The implementation decission which comes up is how to handle this data? Initially you won't notice any issues because either you use a database, some property files or constant variables you just did it actually the right way! But wait - what about if data changes? Who recognize a new currency code? Who updates the new country code? Is there a responsible for checking for updates in the iso xyz?

The Solution

The tcmj-pug-enum project is an effort to provide a complete toolkit to manage data and keep them up to date. The concept behind is, that we have access to a datasource where we can access and fetch our always actual data. If necessary we transform the records in order to bring it in the format that we need for persistency. Because we want something immutable we chose

          **Java Enum**

Implementation Details

As already introduced before we have

  • some kind of data source
  • a model class to temporary hold the data records
  • several mechanics to apply transformations on the input data
  • as a big part of the solution we use external libraries to create a java enum object out of the model
  • and last but not least we have some implementations to export the enum into file system or directly into a classloader

No coding - just configuration

To answer the question 'why not simply create an enum by myself?'

  • developers are not just lazy but did you have ever created a java enum class with more than ten constants? This would take a huge amount of effort and then we do not solved the updating process! The tcmj-pug-enums project provides all java tools to code all your static data together into several java enum objects. But now comes the awesomeness! We got one step further and put all those neat tools into a ** tcmj pug enums maven plugin ** and now you can do the following:

  • Build a empty maven project. No java classes - just a pom.xml and bind our plugin to the build phase!

  • Configure a bunch of options like

  • your classname

  • the url where to fetch your data (wikipedia seems to be great for many cases!)

  • define the table and columns you want to import

  • and just do a ** install ** on your maven project

After the magic happens you will find automagically your enum class in the source code directory. As up-to-date it can ever be and ready to use! Put your new maven project into your build server and you can directly use your lib wherever you desire!