feat: added notification pattern (#2629)

Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
This commit is contained in:
sugavanesh
2024-03-09 18:16:46 +05:30
committed by GitHub
parent b2ca49a4e5
commit 249efd1e71
17 changed files with 849 additions and 0 deletions
@@ -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();
}
}