View Javadoc
1   /*
2    * Copyright (c) 2002-2022, City of 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.appointment.web.dto;
35  
36  import java.util.Objects;
37  
38  import fr.paris.lutece.plugins.genericattributes.business.Entry;
39  import fr.paris.lutece.plugins.genericattributes.business.Field;
40  import fr.paris.lutece.plugins.genericattributes.business.Response;
41  import fr.paris.lutece.portal.business.file.File;
42  
43  /**
44   * DTO that represent a response to display a recap
45   * 
46   * @author Laurent Payen
47   *
48   */
49  public final class ResponseRecapDTO extends Response implements Comparable<ResponseRecapDTO>
50  {
51      /**
52       * Serial version UID
53       */
54      private static final long serialVersionUID = -248405445729375667L;
55  
56      /**
57       * The recap value
58       */
59      private String _strRecapValue;
60  
61      /**
62       * The response
63       */
64      private Response _response;
65  
66      /**
67       * Creates a new response DTO for recap from a response
68       * 
69       * @param response
70       *            The response
71       */
72      public ResponseRecapDTO( Response response )
73      {
74          this._response = response;
75      }
76  
77      /**
78       * Creates a new response DTO for recap from a response
79       * 
80       * @param response
81       *            The response
82       * @param strRecapValue
83       *            The recap value
84       */
85      public ResponseRecapDTO( Response response, String strRecapValue )
86      {
87          this._response = response;
88          this._strRecapValue = strRecapValue;
89      }
90  
91      /**
92       * Get the recap value of this response
93       * 
94       * @return The recap value of this response
95       */
96      public String getRecapValue( )
97      {
98          return this._strRecapValue;
99      }
100 
101     /**
102      * Set the recap value of this response
103      * 
104      * @param strRecapValue
105      *            The recap value of this response
106      */
107     public void setRecapValue( String strRecapValue )
108     {
109         this._strRecapValue = strRecapValue;
110     }
111 
112     /**
113      * {@inheritDoc}
114      */
115     @Override
116     public Entry getEntry( )
117     {
118         return _response.getEntry( );
119     }
120 
121     /**
122      * {@inheritDoc}
123      */
124     @Override
125     public int getIdResponse( )
126     {
127         return _response.getIdResponse( );
128     }
129 
130     /**
131      * {@inheritDoc}
132      */
133     @Override
134     public Field getField( )
135     {
136         return _response.getField( );
137     }
138 
139     /**
140      * {@inheritDoc}
141      */
142     @Override
143     public String getToStringValueResponse( )
144     {
145         return _response.getToStringValueResponse( );
146     }
147 
148     /**
149      * {@inheritDoc}
150      */
151     @Override
152     public String getResponseValue( )
153     {
154         return _response.getResponseValue( );
155     }
156 
157     /**
158      * {@inheritDoc}
159      */
160     @Override
161     public int getStatus( )
162     {
163         return _response.getStatus( );
164     }
165 
166     /**
167      * {@inheritDoc}
168      */
169     @Override
170     public File getFile( )
171     {
172         return _response.getFile( );
173     }
174 
175     @Override
176     public int compareTo( ResponseRecapDTO o )
177     {
178 
179         if ( this._response.getEntry( ) != null && o._response.getEntry( ) != null )
180         {
181             return ( this._response.getEntry( ).getPosition( ) - o._response.getEntry( ).getPosition( ) );
182         }
183         return 0;
184     }
185 
186     @Override
187     public boolean equals( Object o )
188     {
189         if ( o == this )
190         {
191             return true;
192         }
193         if ( !( o instanceof ResponseRecapDTO ) )
194         {
195             return false;
196         }
197         ResponseRecapDTOfr/paris/lutece/plugins/appointment/web/dto/ResponseRecapDTO.html#ResponseRecapDTO">ResponseRecapDTO responseToCompare = (ResponseRecapDTO) o;
198         return Objects.equals( _strRecapValue, responseToCompare._strRecapValue ) && Objects.equals( _response, responseToCompare._response );
199     }
200 
201     @Override
202     public int hashCode( )
203     {
204         return Objects.hash( _strRecapValue, _response );
205     }
206 
207 }