Menu

GeneratorRules

Walter Lyrer

Converter Generation Rules

  1. Packages and directories are not created. They must already exist. Otherwise generation fails.
  2. No existing Java Source files are overwritten. When you need to generate a class anew then you must delete the appropriate file before Converter Generator execution. You can query the generation result from the returned GenerationResult instance.
  3. The Generator Converter tries to match bean names and types of the FROM and TO class. Depending on the match result different code is generated:
    3.1. One bean exists only in the from class:
    - // TODO adjust following line - missing in to instance
    - // to.setBean(from.getBean());
    3.2. One bean exists only in the to class:
    - // TODO adjust following line - missing in from instance
    - // to.setBean(from.getBean());
    3.3. Two beans have the same name and the same type:
    - to.setBean(from.getBean());
    3.4. Two beans have the same name but different types:
    - A new converter is generated recursively for the bean's from and to classes.
    - The converter is generated as as field in the first converter (code varies depending on IntegrationType):
    - private BeanConverter<Bean1, Bean2> beanConverter;
    - The converter is used to convert the bean:
    - to.setBean(beanConverter.convert(from.getBean()));
  4. In normal cases the matching of bean names is achieved only when the a complete bean name matches. However, you can change this behaviour a little bit by setting a beanNameConversionList in the Global Properties.
  5. Please note that there is a 1:1 mapping.
  6. The bean name conversion list is applied for all converters generated in the same generation run. This may cause unwanted side effects. Please, check the generated code more carefully when using beanNameConversionList.

Copyright

Copyright by Walter Lyrer

Disclaimer

The author cannot be made responsible for any damage caused by the Converter Generator.
The usage of the Converter Generator is on own risk.
The code is designed and implemented on best know-how and with good intensions by the author.
Especially is to mention that the generated code of the Converter Generator is not guaranteed to run instantly correct.
Manual supervision is necessary.

Author

Walter Lyrer

Other projects from same author

Jacoge Java Generator Eclipse Plugin
Strategy/State Generator
Visitor Generator
Named Parameter Converter

Project Members:


Related

Wiki: GeneratorDocumentation