Skip to content

Commit

Permalink
feat: introduce ContactEntryType enum replacing type string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
keshavbhatt committed Apr 12, 2024
1 parent 268e3fd commit cd5e26c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
16 changes: 16 additions & 0 deletions store/src/main/java/com/zimbra/cs/mailbox/ContactAutoComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ void clear() {

}

public enum ContactEntryType {
GAL("gal"),
RANKING_TABLE("rankingTable"),
CONTACT("contact");

public String getName() {
return name;
}

private final String name;

ContactEntryType(String name) {
this.name = name;
}
}

public static final class ContactEntry implements Comparable<ContactEntry> {
String mEmail;
String mDisplayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package com.zimbra.cs.service.mail;

import com.zimbra.cs.mailbox.ContactAutoComplete.ContactEntryType;
import java.util.ArrayList;
import java.util.Map;

Expand Down Expand Up @@ -85,7 +86,7 @@ protected AutoCompleteResult query(Element request, ZimbraSoapContext zsc, Accou
protected void toXML(Element response, AutoCompleteResult result, String authAccountId) {
response.addAttribute(MailConstants.A_CANBECACHED, result.canBeCached);
for (ContactEntry entry : result.entries) {
Element cn = response.addElement(MailConstants.E_MATCH);
Element cn = response.addNonUniqueElement(MailConstants.E_MATCH);

// for contact group, emails of members will be expanded
// separately on user request
Expand Down Expand Up @@ -151,10 +152,10 @@ protected void toXML(Element response, AutoCompleteResult result, String authAcc

private String getType(ContactEntry entry) {
if (entry.getFolderId() == ContactAutoComplete.FOLDER_ID_GAL)
return "gal";
return ContactEntryType.GAL.getName();
else if (entry.getFolderId() == ContactAutoComplete.FOLDER_ID_UNKNOWN)
return "rankingTable";
return ContactEntryType.RANKING_TABLE.getName();
else
return "contact";
return ContactEntryType.CONTACT.getName();
}
}

0 comments on commit cd5e26c

Please sign in to comment.