refactor: make functions static

This commit is contained in:
Anthony Berg 2024-10-15 15:50:07 +02:00
parent 0dbd6eb471
commit 74d4189808
2 changed files with 3 additions and 3 deletions

View File

@ -6,7 +6,7 @@ public class EMail {
* @param email The email address being checked
* @return <code>true</code> if the email is correctly formatted, otherwise <code>false</code>
*/
public boolean validate(String email) {
public static boolean validate(String email) {
// Set up regex for email format
String emailRegex = "[^@ \\t\\r\\n]+@[^@ \\t\\r\\n]+\\.[^@ \\t\\r\\n]+";
Pattern pattern = Pattern.compile(emailRegex);
@ -20,7 +20,7 @@ public class EMail {
* @param email A valid email address
* @return The domain of the email address from the parameter
*/
public String getDomain(String email) {
public static String getDomain(String email) {
// Checks that the email address is valid, otherwise throw exception
if (!validate(email)) {
throw new IllegalArgumentException("The email address provided is not valid");

View File

@ -10,7 +10,7 @@ public class ReadFile {
* @param filename the name of the file with, only allowing a .txt extension
* @return The contents of the file
*/
public List<String> open(String filename) {
public static List<String> open(String filename) {
// Check that the filetype is correct, otherwise, throw IllegalArgumentException
if (!filename.endsWith(".txt")) {
throw new IllegalArgumentException("The filename is not a .txt format");