Annotation Interface Domain


@Target(TYPE) @Retention(RUNTIME) public @interface Domain
Indicates a domain class.

A domain class is a user-defined type that wraps a basic value. It can be mapped to a database column.

Instantiation by constructor:

 @Domain(valueType = String.class)
 public class PhoneNumber {

     private final String value;

     public PhoneNumber(String value) {
         this.value = value;
     }

     public String getValue() {
         return value;
     }
 }
 
Instantiation by factory method:
 @Domain(valueType = String.class, factoryMethod = "of")
 public class PhoneNumber {

     private final String value;

     private PhoneNumber(String value) {
         this.value = value;
     }

     public String getValue() {
         return value;
     }

     public static PhoneNumber of(String value) {
         return new PhoneNumber(value);
     }
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
     
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
     
    The accessor method name.
    The factory method name.
  • Element Details

    • valueType

      Class<?> valueType
      Returns:
      the value type that is wrapped by this domain class.
    • factoryMethod

      String factoryMethod
      The factory method name.

      The factory method that accepts the wrapped value as an argument.

      The default value "new" means constructor usage.

      Returns:
      the method name
      Default:
      "new"
    • accessorMethod

      String accessorMethod
      The accessor method name.

      The accessor method returns the wrapped value.

      Returns:
      the method name
      Default:
      "getValue"
    • acceptNull

      boolean acceptNull
      Returns:
      whether the constructor or the factory method should accept null as an argument.
      Default:
      false