'Added simply MailClient mockup;'

This commit is contained in:
Arkadiusz Hypki 2024-03-04 15:49:43 +01:00
parent 09153fccde
commit 324989f8ae
10 changed files with 174 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,8 @@
package net.hypki.mailclient.db;
import java.io.IOException;
public interface Db {
public void save(String key, Object value) throws IOException;
public Object get(String key);
}

View File

@ -0,0 +1,22 @@
package net.hypki.mailclient.db.sql;
import net.hypki.mailclient.db.Db;
import java.io.IOException;
public class MySQLDB implements Db {
@Override
public void save(String key, Object value) throws IOException {
// 1. opening a client to a real databse
// 2. put object to real database
// 3. check for errors
}
@Override
public Object get(String key) {
// 1. open a client to a database
// 2. return data from DB
// 3. convert to Object and return it
return null;
}
}

View File

@ -0,0 +1,57 @@
package net.hypki.mailclient.model;
import java.io.IOException;
public class Mail extends ModelObject {
private String id = null;
private String title = null;
private String from = null;
private String to = null;
public Mail() {
}
@Override
public void validate() throws IOException, IllegalArgumentException {
// if `to` mail is incorrect then throw exception
if (!to.contains("@"))
throw new IOException("bbbbbb");
}
public String getTitle() {
// additions
// someFunction()
return title;
}
public void setTitle(String newTitle) {
this.title = newTitle;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}

View File

@ -0,0 +1,7 @@
package net.hypki.mailclient.model;
import java.io.IOException;
public abstract class ModelObject {
public abstract void validate() throws IOException, IllegalArgumentException;
}

View File

@ -0,0 +1,36 @@
package net.hypki.mailclient.model;
import java.io.IOException;
public class User extends ModelObject {
private String email = null;
private String name = null;
public User() {
}
@Override
public void validate() throws IOException, IllegalArgumentException {
// if `to` mail is incorrect then throw exception
if (!email.contains("@"))
throw new IOException("bbbbbb");
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,27 @@
package net.hypki.mailclient.view;
import net.hypki.mailclient.db.Db;
import net.hypki.mailclient.db.sql.MySQLDB;
import net.hypki.mailclient.model.Mail;
import javax.activation.MailcapCommandMap;
public class MainUI {
private Db database = null;
public MainUI() {
database = new MySQLDB();
}
public void showMainDialog() {
// show UI
while (true) {
// check evey 5 mins for new mails
Mail newMail = new Mail();
database.save(newMail.getId(), newMail);
}
}
}