1 /*
2 * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
3 * Copyright (C) 2010 Mickael Guessant
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 package davmail.exchange.ews;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 /**
25 * Distinguished Folder Id.
26 */
27 public final class DistinguishedFolderId extends FolderId {
28
29 private DistinguishedFolderId(String value) {
30 super("t:DistinguishedFolderId", value, null);
31 }
32
33 private DistinguishedFolderId(String value, String mailbox) {
34 super("t:DistinguishedFolderId", value, null, mailbox);
35 }
36
37 /**
38 * DistinguishedFolderId names
39 */
40 @SuppressWarnings({"UnusedDeclaration"})
41 public enum Name {
42 calendar, contacts, deleteditems, drafts, inbox, journal, notes, outbox, sentitems, tasks, msgfolderroot,
43 publicfoldersroot, root, junkemail, searchfolders, voicemail,
44 archivemsgfolderroot
45 }
46
47 private static final Map<Name, DistinguishedFolderId> folderIdMap = new HashMap<>();
48
49 static {
50 for (Name name : Name.values()) {
51 folderIdMap.put(name, new DistinguishedFolderId(name.toString()));
52 }
53 }
54
55 /**
56 * Get DistinguishedFolderId object for mailbox and name.
57 *
58 * @param mailbox mailbox name
59 * @param name folder id name
60 * @return DistinguishedFolderId object
61 */
62 public static DistinguishedFolderId getInstance(String mailbox, Name name) {
63 if (mailbox == null) {
64 return folderIdMap.get(name);
65 } else {
66 return new DistinguishedFolderId(name.toString(), mailbox);
67 }
68 }
69
70 }