mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-28 00:26:03 +00:00
feat: added notification pattern (#2629)
Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package com.iluwatar;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* The notification pattern captures information passed between layers, validates the information, and returns
|
||||
* any errors to the presentation layer if needed.
|
||||
*
|
||||
* <p>In this code, this pattern is implemented through the example of a form being submitted to register
|
||||
* a worker. The worker inputs their name, occupation, and date of birth to the RegisterWorkerForm (which acts
|
||||
* as our presentation layer), and passes it to the RegisterWorker class (our domain layer) which validates it.
|
||||
* Any errors caught by the domain layer are then passed back to the presentation layer through the
|
||||
* RegisterWorkerDto.</p>
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static final String NAME = "";
|
||||
private static final String OCCUPATION = "";
|
||||
private static final LocalDate DATE_OF_BIRTH = LocalDate.of(2016, 7, 13);
|
||||
|
||||
public static void main(String[] args) {
|
||||
var form = new RegisterWorkerForm(NAME, OCCUPATION, DATE_OF_BIRTH);
|
||||
form.submit();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user