From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/java/notifyMe/.gitignore | 38 ++++++ graphs/java/notifyMe/pom.xml | 133 +++++++++++++++++++++ .../notifyme/notify/INotificationSender.java | 10 ++ .../assistants/notifyme/notify/ShellNotifier.java | 22 ++++ .../notifyme/user/IMultiNotificationSender.java | 26 ++++ .../fr/epita/assistants/notifyme/user/User.java | 41 +++++++ 6 files changed, 270 insertions(+) create mode 100644 graphs/java/notifyMe/.gitignore create mode 100644 graphs/java/notifyMe/pom.xml create mode 100644 graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/INotificationSender.java create mode 100644 graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/ShellNotifier.java create mode 100644 graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/IMultiNotificationSender.java create mode 100644 graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/User.java (limited to 'graphs/java/notifyMe') diff --git a/graphs/java/notifyMe/.gitignore b/graphs/java/notifyMe/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/graphs/java/notifyMe/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/graphs/java/notifyMe/pom.xml b/graphs/java/notifyMe/pom.xml new file mode 100644 index 0000000..67e31e2 --- /dev/null +++ b/graphs/java/notifyMe/pom.xml @@ -0,0 +1,133 @@ + + + 4.0.0 + fr.epita.assistants + notifyMe + 1.0 + + + 21 + 5.9.1 + 3.13.0 + 3.5.0 + 3.1.1 + 3.1.0 + + UTF-8 + + ${project.build.directory}/surefire-reports + + + + + org.junit.jupiter + junit-jupiter + ${versions.junit} + + + org.apache.maven.surefire + surefire-junit-platform + ${versions.maven-surefire-plugin} + + + org.apache.maven + maven-compat + 3.9.8 + + + org.apache.maven + maven-plugin-api + 3.9.8 + + + org.apache.maven + maven-project + 2.2.1 + + + org.apache.maven + maven-core + 3.8.1 + + + org.apache.maven + maven-monitor + 2.2.1 + + + org.codehaus.plexus + plexus-utils + 3.0.24 + + + org.apache.maven.shared + maven-filtering + 3.3.2 + + + org.codehaus.plexus + plexus-interpolation + 1.13 + + + org.apache.maven + maven-profile + 2.2.1 + + + org.apache.maven + maven-artifact-manager + 2.2.1 + + + org.apache.maven + maven-plugin-registry + 2.2.1 + + + org.apache.maven + maven-repository-metadata + 2.2.1 + + + classworlds + classworlds + 1.1 + + + org.junit.platform + junit-platform-commons + 1.9.3 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${versions.maven-compiler-plugin} + + ${versions.java} + ${versions.java} + + + + org.apache.maven.plugins + maven-install-plugin + ${versions.maven-install-plugin} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${versions.maven-surefire-plugin} + + ${surefire.reportsDirectory} + + + + + diff --git a/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/INotificationSender.java b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/INotificationSender.java new file mode 100644 index 0000000..6146e8e --- /dev/null +++ b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/INotificationSender.java @@ -0,0 +1,10 @@ +package fr.epita.assistants.notifyme.notify; + +public interface INotificationSender { + /** + * Entrypoint to send notifications. + * @param parMessage the message to use for the notification - may be discarded by the␣ + ↪→implementation + */ + void notify(final String parSender, final String parReceiver, final String parMessage); +} diff --git a/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/ShellNotifier.java b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/ShellNotifier.java new file mode 100644 index 0000000..c2631f7 --- /dev/null +++ b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/ShellNotifier.java @@ -0,0 +1,22 @@ +package fr.epita.assistants.notifyme.notify; + +public class ShellNotifier implements INotificationSender { + final boolean err; + + /** + * Constructor + * + * @param parStdErr if true, print to stderr, otherwise print to stdout + */ + public ShellNotifier(final boolean parStdErr) { + err = parStdErr; + } + + @Override + public void notify(String parSender, String parReceiver, String parMessage) { + if (err) + System.err.println("Notification from " + parSender + " to " + parReceiver + " received: " + parMessage); + else + System.out.println("Notification from " + parSender + " to " + parReceiver + " received: " + parMessage); + } +} diff --git a/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/IMultiNotificationSender.java b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/IMultiNotificationSender.java new file mode 100644 index 0000000..501a070 --- /dev/null +++ b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/IMultiNotificationSender.java @@ -0,0 +1,26 @@ +package fr.epita.assistants.notifyme.user; + +import fr.epita.assistants.notifyme.notify.INotificationSender; + +import java.util.List; + +public interface IMultiNotificationSender { + /** + * Sends a notification to all registered notifiers + * @param parRecipient the recipient of the notification + * @param parMessage the message to send + */ + void sendNotifications(String parRecipient, String parMessage); + + /** + * Adds a notification sender to the list of possible recipients + * @param parNotifier the new notifier to add, should be ignored if null + */ + void addNotifier(INotificationSender parNotifier); + + /** + * Returns the list of notifiers + * @return the list of notifiers + */ + List getNotifiers(); +} diff --git a/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/User.java b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/User.java new file mode 100644 index 0000000..58d4446 --- /dev/null +++ b/graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/User.java @@ -0,0 +1,41 @@ +package fr.epita.assistants.notifyme.user; + +import fr.epita.assistants.notifyme.notify.INotificationSender; + +import java.util.ArrayList; +import java.util.List; + +public class User implements IMultiNotificationSender { + final List parNotificationList; + final String username; + + public String getUsername() { + return username; + } + + public User(String username) { + this.username = username; + this.parNotificationList = new ArrayList<>(); + } + + public User(String username, List parNotificationList) { + this.parNotificationList = parNotificationList; + this.username = username; + } + + @Override + public void sendNotifications(String parRecipient, String parMessage) { + for (INotificationSender n : parNotificationList) + n.notify(username, parRecipient, parMessage); + } + + @Override + public void addNotifier(INotificationSender parNotifier) { + parNotificationList.add(parNotifier); + } + + @Override + public List getNotifiers() { + return parNotificationList; + } +} -- cgit v1.2.3