summaryrefslogtreecommitdiff
path: root/graphs/java/notifyMe
diff options
context:
space:
mode:
Diffstat (limited to 'graphs/java/notifyMe')
-rw-r--r--graphs/java/notifyMe/.gitignore38
-rw-r--r--graphs/java/notifyMe/pom.xml133
-rw-r--r--graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/INotificationSender.java10
-rw-r--r--graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/notify/ShellNotifier.java22
-rw-r--r--graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/IMultiNotificationSender.java26
-rw-r--r--graphs/java/notifyMe/src/main/java/fr/epita/assistants/notifyme/user/User.java41
6 files changed, 270 insertions, 0 deletions
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>fr.epita.assistants</groupId>
+ <artifactId>notifyMe</artifactId>
+ <version>1.0</version>
+
+ <properties>
+ <versions.java>21</versions.java>
+ <versions.junit>5.9.1</versions.junit>
+ <versions.maven-compiler-plugin>3.13.0</versions.maven-compiler-plugin>
+ <versions.maven-surefire-plugin>3.5.0</versions.maven-surefire-plugin>
+ <versions.maven-jar-plugin>3.1.1</versions.maven-jar-plugin>
+ <versions.maven-install-plugin>3.1.0</versions.maven-install-plugin>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <surefire.reportsDirectory>${project.build.directory}/surefire-reports</surefire.reportsDirectory>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
+ <version>${versions.junit}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.surefire</groupId>
+ <artifactId>surefire-junit-platform</artifactId>
+ <version>${versions.maven-surefire-plugin}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>3.9.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.9.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-monitor</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.24</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-filtering</artifactId>
+ <version>3.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interpolation</artifactId>
+ <version>1.13</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-profile</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact-manager</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-registry</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-repository-metadata</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.platform</groupId>
+ <artifactId>junit-platform-commons</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${versions.maven-compiler-plugin}</version>
+ <configuration>
+ <source>${versions.java}</source>
+ <target>${versions.java}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>${versions.maven-install-plugin}</version>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${versions.maven-surefire-plugin}</version>
+ <configuration>
+ <reportsDirectory>${surefire.reportsDirectory}</reportsDirectory>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
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<INotificationSender> 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<INotificationSender> 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<INotificationSender> 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<INotificationSender> getNotifiers() {
+ return parNotificationList;
+ }
+}