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 -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanThe 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 factoryMethodThe 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 accessorMethodThe 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
nullas an argument.
- Default:
- false
-