Define Converters and Populators?

The Conversion between models and data objects is done by the converters and populators.

  • converter may create object and contains a list of populators.
  •  populator files in some fields (or calculates using services) of the data object to be used in the front-end.
  • Populators must be independent and must have a clear goal, so they can be easily reused.
  • Both are injected using Spring. The new constructor must be avoid.

   

       Converter.java

               public interface Converter<S, T>

                {

                   T convert(S source) throws ConversionException;

                }

 

          Populator.java

               public interface Populator<S, T>

{

    void populate(S source, T target) throws ConversionException, IllegalArgumentException;

    void populateFinals(S source, T target) throws ConversionException, IllegalArgumentException;

 }

No comments:

Post a Comment