BrightSide Workbench Full Report + Source Code
JsonMailStructure.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2023 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (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 Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.mail.json;
20 
21 import java.util.ArrayList;
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25 import javax.json.JsonValue;
26 import org.turro.json.IJSONizable;
27 
32 public class JsonMailStructure implements IJSONizable {
33 
34  private String category, subject, message;
35  private boolean administrators;
36  private List<String> entityPaths = new ArrayList<>();
37  private List<String> contactIds = new ArrayList<>();
38  private Map<String, String> users = new HashMap<>();
39 
40  public String getCategory() {
41  return category;
42  }
43 
44  public void setCategory(String category) {
45  this.category = category;
46  }
47 
48  public String getSubject() {
49  return subject;
50  }
51 
52  public void setSubject(String subject) {
53  this.subject = subject;
54  }
55 
56  public String getMessage() {
57  return message;
58  }
59 
60  public void setMessage(String message) {
61  this.message = message;
62  }
63 
64  public boolean isAdministrators() {
65  return administrators;
66  }
67 
68  public void setAdministrators(boolean administrators) {
69  this.administrators = administrators;
70  }
71 
72  public List<String> getEntityPaths() {
73  return entityPaths;
74  }
75 
76  public void setEntityPaths(List<String> entityPaths) {
77  this.entityPaths = entityPaths;
78  }
79 
80  public List<String> getContactIds() {
81  return contactIds;
82  }
83 
84  public void setContactIds(List<String> contactIds) {
85  this.contactIds = contactIds;
86  }
87 
88  public Map<String, String> getUsers() {
89  return users;
90  }
91 
92  public void setUsers(Map<String, String> users) {
93  this.users = users;
94  }
95 
96  /* Define */
97 
98  public JsonMailStructure category(String category) {
99  setCategory(category);
100  return this;
101  }
102 
103  public JsonMailStructure message(String message) {
104  setMessage(message);
105  return this;
106  }
107 
109  setAdministrators(true);
110  return this;
111  }
112 
114  entityPaths.add(entityPath);
115  return this;
116  }
117 
118  public JsonMailStructure add(String contactId) {
119  contactIds.add(contactId);
120  return this;
121  }
122 
123  public JsonMailStructure add(String name, String email) {
124  users.put(name, email);
125  return this;
126  }
127 
128  /* Factory */
129 
130  public static JsonMailStructure subject(String subject) {
131  JsonMailStructure structure = new JsonMailStructure();
132  structure.setSubject(subject);
133  return structure;
134  }
135 
136  /* IJSONizable */
137 
138  @Override
139  public String toJson() {
140  return toJson(this);
141  }
142 
143  @Override
144  public String toJson(Map<String, Object> properties) {
145  return toJson(this, properties);
146  }
147 
148  public static JsonMailStructure fromJson(JsonValue value) {
149  return IJSONizable.fromJson(value.toString(), JsonMailStructure.class);
150  }
151 
152 }
void setUsers(Map< String, String > users)
JsonMailStructure add(String contactId)
JsonMailStructure category(String category)
String toJson(Map< String, Object > properties)
JsonMailStructure entityPath(String entityPath)
void setEntityPaths(List< String > entityPaths)
JsonMailStructure message(String message)
JsonMailStructure add(String name, String email)
void setContactIds(List< String > contactIds)
static JsonMailStructure subject(String subject)
static JsonMailStructure fromJson(JsonValue value)
void setAdministrators(boolean administrators)