View Javadoc
1   package fr.ifremer.dali.service.control;
2   
3   /*
4    * #%L
5    * Dali :: UI
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2014 - 2015 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU Affero General Public License as published by
13   * the Free Software Foundation, either version 3 of the License, or
14   * (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU Affero General Public License
22   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23   * #L%
24   */
25  
26  import java.util.ArrayList;
27  import java.util.Date;
28  import java.util.List;
29  
30  /**
31   * Rules control bean.
32   */
33  public class ControlRuleMessagesBean {
34  
35      /**
36       * Error messages.
37       */
38      private List<String> errorMessages;
39  
40      /**
41       * Warning messages.
42       */
43      private List<String> warningMessages;
44  
45      /**
46       * Date when the control has been made
47       */
48      private Date controlDate;
49  
50      /**
51       * Constructor.
52       *
53       * @param controlDate a {@link java.util.Date} object.
54       */
55      public ControlRuleMessagesBean(Date controlDate) {
56          errorMessages = new ArrayList<>();
57          warningMessages = new ArrayList<>();
58          this.controlDate = controlDate;
59      }
60  
61      /**
62       * <p>Getter for the field <code>controlDate</code>.</p>
63       *
64       * @return a {@link java.util.Date} object.
65       */
66      public Date getControlDate() {
67          return controlDate;
68      }
69  
70      /**
71       * If exists error message.
72       *
73       * @return True or false
74       */
75      public boolean isErrorMessages() {
76          return !errorMessages.isEmpty();
77      }
78  
79      /**
80       * If exists warning message.
81       *
82       * @return True or false
83       */
84      public boolean isWarningMessages() {
85          return !warningMessages.isEmpty();
86      }
87  
88      /**
89       * <p>Getter for the field <code>errorMessages</code>.</p>
90       *
91       * @return a {@link java.util.List} object.
92       */
93      public List<String> getErrorMessages() {
94          return errorMessages;
95      }
96  
97      public void addErrorMessage(String errorMessage) {
98          errorMessages.add(errorMessage);
99      }
100 
101     /**
102      * <p>Getter for the field <code>warningMessages</code>.</p>
103      *
104      * @return a {@link java.util.List} object.
105      */
106     public List<String> getWarningMessages() {
107         return warningMessages;
108     }
109 
110     public void addWarningMessage(String warningMessage) {
111         warningMessages.add(warningMessage);
112     }
113 }