1 | package edu.ucsb.cs156.frontiers.utilities; | |
2 | ||
3 | public class CanonicalFormConverter { | |
4 | ||
5 | /** | |
6 | * Converts an email address to a valid canonical form. | |
7 | * | |
8 | * <p>Some universities may have email systems where there are multiple valid representations of | |
9 | * the same email address. | |
10 | * | |
11 | * <p>This method ensures that the email is in a consistent canonical form. This is the place to | |
12 | * isolate these conversions, so that if the rules change, we only have to change them in one | |
13 | * place. | |
14 | * | |
15 | * @param email | |
16 | * @return email in canonical form | |
17 | */ | |
18 | public static String convertToValidEmail(String email) { | |
19 | String canonicalEmail = email.replace("@umail.ucsb.edu", "@ucsb.edu").toLowerCase(); | |
20 |
1
1. convertToValidEmail : replaced return value with "" for edu/ucsb/cs156/frontiers/utilities/CanonicalFormConverter::convertToValidEmail → KILLED |
return canonicalEmail; |
21 | } | |
22 | ||
23 | /** | |
24 | * Check whether two emails are equivalent in their canonical form | |
25 | * | |
26 | * @param email1 | |
27 | * @param email2 | |
28 | * @return true if the canonical forms of the two emails are equal, false otherwise | |
29 | */ | |
30 | public static boolean areEquivalentEmails(String email1, String email2) { | |
31 |
2
1. areEquivalentEmails : replaced boolean return with true for edu/ucsb/cs156/frontiers/utilities/CanonicalFormConverter::areEquivalentEmails → KILLED 2. areEquivalentEmails : replaced boolean return with false for edu/ucsb/cs156/frontiers/utilities/CanonicalFormConverter::areEquivalentEmails → KILLED |
return convertToValidEmail(email1).equals(convertToValidEmail(email2)); |
32 | } | |
33 | } | |
Mutations | ||
20 |
1.1 |
|
31 |
1.1 2.2 |