1 /*
2 * Copyright 2018-2022 Medical Information Systems Research Group (https://medical.zcu.cz),
3 * Department of Computer Science and Engineering, University of West Bohemia.
4 * Address: Univerzitni 8, 306 14 Plzen, Czech Republic.
5 *
6 * Author Petr Vcelak (vcelak@kiv.zcu.cz).
7 *
8 * This file is part of MRECore project.
9 *
10 * MRECore is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License.
13 *
14 * MRECore is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with MRECore. If not, see <http://www.gnu.org/licenses/>.
21 */
22 package cz.zcu.mre.data.support;
23
24 /**
25 * A message to be displayed in web context. Depending on the type, different
26 * style will be applied.
27 *
28 * @author Petr Vcelak (vcelak@kiv.zcu.cz)
29 */
30 public class Message implements java.io.Serializable {
31
32 /**
33 * Name of the flash attribute.
34 */
35 public static final String MESSAGE_ATTRIBUTE = "message";
36
37 /**
38 * The type of the message to be displayed. The type is used to show message
39 * in a different style.
40 */
41 public static enum Type {
42 DANGER, WARNING, INFO, SUCCESS;
43 }
44
45 private final String message;
46 private final Type type;
47 private final Object[] args;
48
49 public Message(String message, Type type) {
50 this.message = message;
51 this.type = type;
52 this.args = null;
53 }
54
55 public Message(String message, Type type, Object... args) {
56 this.message = message;
57 this.type = type;
58 this.args = args;
59 }
60
61 public String getMessage() {
62 return message;
63 }
64
65 public Type getType() {
66 return type;
67 }
68
69 public Object[] getArgs() {
70 return args.clone();
71 }
72 }