1 package se.citerus.dddsample.domain.shared;
2
3 /**
4 * Utility code for domain classes.
5 *
6 */
7 public class DomainObjectUtils {
8
9 /**
10 * @param actual actual value
11 * @param safe a null-safe value
12 * @param <T> type
13 * @return actual value, if it's not null, or safe value if the actual value is null.
14 */
15 public static <T> T nullSafe(T actual, T safe) {
16 return actual == null ? safe : actual;
17 }
18
19 // TODO wrappers for some of the commons-lang code:
20 //
21 // EqualsBuilder that uses sameIdentity/sameValue,
22 // better validation (varargs etc)
23
24 /**
25 * Prevent instantiation.
26 */
27 private DomainObjectUtils() {
28 }
29
30 }