View Javadoc
1   /*
2    * Copyright (c) 2002-2018, Mairie de Paris
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions
7    * are met:
8    *
9    *  1. Redistributions of source code must retain the above copyright notice
10   *     and the following disclaimer.
11   *
12   *  2. Redistributions in binary form must reproduce the above copyright notice
13   *     and the following disclaimer in the documentation and/or other materials
14   *     provided with the distribution.
15   *
16   *  3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its
17   *     contributors may be used to endorse or promote products derived from
18   *     this software without specific prior written permission.
19   *
20   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30   * POSSIBILITY OF SUCH DAMAGE.
31   *
32   * License 1.0
33   */
34  package fr.paris.lutece.plugins.easyrulesbot.service.yaml.model;
35  
36  import java.util.List;
37  
38  /**
39   * YamlRule
40   */
41  public class YamlRule
42  {
43      // Variables declarations
44      private String _strRule;
45      private String _strDescription;
46      private int _nPriority;
47      private String _strMessage;
48      private List<YamlButton> _listButtons;
49      private String _strImage;
50      private String _strDataKey;
51      private String _strProcessor;
52      private List<YamlCondition> _listConditions;
53      private String _strResponseComment;
54  
55      /**
56       * Returns the Rule Name
57       * 
58       * @return The Rule Name
59       */
60      public String getRule( )
61      {
62          return _strRule;
63      }
64  
65      /**
66       * Sets the Rule Name
67       * 
68       * @param strRule
69       *            The Rule Name
70       */
71      public void setRule( String strRule )
72      {
73          _strRule = strRule;
74      }
75  
76      /**
77       * Returns the Description
78       * 
79       * @return The Description
80       */
81      public String getDescription( )
82      {
83          return _strDescription;
84      }
85  
86      /**
87       * Sets the Description
88       * 
89       * @param strDescription
90       *            The Description
91       */
92      public void setDescription( String strDescription )
93      {
94          _strDescription = strDescription;
95      }
96  
97      /**
98       * Returns the Priority
99       * 
100      * @return The Priority
101      */
102     public int getPriority( )
103     {
104         return _nPriority;
105     }
106 
107     /**
108      * Sets the Priority
109      * 
110      * @param nPriority
111      *            The Priority
112      */
113     public void setPriority( int nPriority )
114     {
115         _nPriority = nPriority;
116     }
117 
118     /**
119      * Returns the Message
120      * 
121      * @return The Message
122      */
123     public String getMessage( )
124     {
125         return _strMessage;
126     }
127 
128     /**
129      * Sets the Message
130      * 
131      * @param strMessage
132      *            The Message
133      */
134     public void setMessage( String strMessage )
135     {
136         _strMessage = strMessage;
137     }
138 
139     /**
140      * Returns the Buttons
141      * 
142      * @return The Buttons
143      */
144     public List<YamlButton> getButtons( )
145     {
146         return _listButtons;
147     }
148 
149     /**
150      * Sets the Buttons
151      * 
152      * @param listButtons
153      *            The Buttons
154      */
155     public void setButtons( List<YamlButton> listButtons )
156     {
157         _listButtons = listButtons;
158     }
159 
160     /**
161      * Returns the Image
162      * 
163      * @return The Image
164      */
165     public String getImage( )
166     {
167         return _strImage;
168     }
169 
170     /**
171      * Sets the Image
172      * 
173      * @param strImage
174      *            The Image
175      */
176     public void setImage( String strImage )
177     {
178         _strImage = strImage;
179     }
180 
181     /**
182      * Returns the DataKey
183      * 
184      * @return The DataKey
185      */
186     public String getDataKey( )
187     {
188         return _strDataKey;
189     }
190 
191     /**
192      * Sets the DataKey
193      * 
194      * @param strDataKey
195      *            The DataKey
196      */
197     public void setDataKey( String strDataKey )
198     {
199         _strDataKey = strDataKey;
200     }
201 
202     /**
203      * Returns the Processor
204      * 
205      * @return The Processor
206      */
207     public String getProcessor( )
208     {
209         return _strProcessor;
210     }
211 
212     /**
213      * Sets the Processor
214      * 
215      * @param strProcessor
216      *            The Processor
217      */
218     public void setProcessor( String strProcessor )
219     {
220         _strProcessor = strProcessor;
221     }
222 
223     /**
224      * Returns the Conditions
225      * 
226      * @return The Conditions
227      */
228     public List<YamlCondition> getConditions( )
229     {
230         return _listConditions;
231     }
232 
233     /**
234      * Sets the Conditions
235      * 
236      * @param listConditions
237      *            The Conditions
238      */
239     public void setConditions( List<YamlCondition> listConditions )
240     {
241         _listConditions = listConditions;
242     }
243 
244     /**
245      * Returns the ResponseComment
246      * 
247      * @return The ResponseComment
248      */
249     public String getResponseComment( )
250     {
251         return _strResponseComment;
252     }
253 
254     /**
255      * Sets the ResponseComment
256      * 
257      * @param strResponseComment
258      *            The ResponseComment
259      */
260     public void setResponseComment( String strResponseComment )
261     {
262         _strResponseComment = strResponseComment;
263     }
264     
265     /**
266      * {@inheritDoc }
267      */
268     @Override
269     public String toString()
270     {
271         StringBuilder sbOutput = new StringBuilder( "\n   RULE");
272         sbOutput.append( "\n   name : " ).append( _strRule );
273         sbOutput.append( "\n   description : " ).append( _strDescription );
274         sbOutput.append( "\n   message : " ).append( _strMessage );
275         sbOutput.append( "\n   priority : " ).append( _nPriority );
276         sbOutput.append( "\n   data key : " ).append( _strDataKey );
277         sbOutput.append( "\n   Conditions : " );
278         if( _listConditions != null )
279         {
280             for( YamlCondition condition : _listConditions )
281             {
282                 sbOutput.append( "\n  " ).append( condition );
283             }
284         }
285         return sbOutput.toString();
286     }
287     
288 }