Interface DomainConverter<DOMAIN,BASIC>

Type Parameters:
DOMAIN - the type of the domain object
BASIC - the type of the basic value
All Known Implementing Classes:
JdbcTypeProvider

public interface DomainConverter<DOMAIN,BASIC>
A converter interface for mapping between domain objects and their corresponding basic values.

The implementation class should be annotated with ExternalDomain.

 @ExternalDomain
 public class SalaryConverter implements DomainConverter<Salary, BigDecimal> {

     public BigDecimal fromDomainToValue(Salary domain) {
         return domain.getValue();
     }

     public Salary fromValueToDomain(BigDecimal value) {
         if (value == null) {
             return null;
         }
         return new Salary(value);
     }
 }
 
See Also:
  • Method Details

    • fromDomainToValue

      BASIC fromDomainToValue(DOMAIN domain)
      Converts a domain object into a basic value.
      Parameters:
      domain - the domain object; must not be null
      Returns:
      the basic value; can be null
    • fromValueToDomain

      DOMAIN fromValueToDomain(BASIC value)
      Converts a basic value into a domain object.
      Parameters:
      value - the basic value; can be null
      Returns:
      the domain object; can be null