Kaynağa Gözat

Introduced interfaces for entity, value object and domain event, extracted from the sameIdentityAs/sameValueAs/sameEventAs methods

peter_backlund 18 yıl önce
ebeveyn
işleme
f2117671d3

+ 17
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/DomainEvent.java Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+package se.citerus.dddsample.domain;
2
+
3
+/**
4
+ * A domain event is something that is unique, but does not have a lifecycle.
5
+ * The identity may be explicit, for example the sequence number of a payment,
6
+ * or it could be derived from various aspects of the event such as where, when and what
7
+ * has happened.
8
+ */
9
+public interface DomainEvent<T> {
10
+
11
+  /**
12
+   * @param other The other domain event.
13
+   * @return <code>true</code> if the given domain event and this event are regarded as being the same event.
14
+   */
15
+  boolean sameEventAs(T other);
16
+
17
+}

+ 17
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/Entity.java Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+package se.citerus.dddsample.domain;
2
+
3
+/**
4
+ * An entity, as explained in the DDD book.
5
+ *  
6
+ */
7
+public interface Entity<T> {
8
+
9
+  /**
10
+   * Entities compare by identity, not by attributes.
11
+   *
12
+   * @param other The other entity.
13
+   * @return true if the identities are the same, regardles of other attributes.
14
+   */
15
+  boolean sameIdentityAs(T other);
16
+
17
+}

+ 17
- 0
dddsample/src/main/java/se/citerus/dddsample/domain/ValueObject.java Dosyayı Görüntüle

@@ -0,0 +1,17 @@
1
+package se.citerus.dddsample.domain;
2
+
3
+/**
4
+ * A value object, as described in the DDD book.
5
+ * 
6
+ */
7
+public interface ValueObject<T> {
8
+
9
+  /**
10
+   * Value objects compare by the values of their attributes, they don't have an identity.
11
+   *
12
+   * @param other The other value object.
13
+   * @return <code>true</code> if the given value object's and this value object's attributes are the same.
14
+   */
15
+  boolean sameValueAs(T other);
16
+
17
+}