TimerGestoreChiaviPDNDEvents.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.pdd.timers.pdnd;

  21. import java.util.ArrayList;
  22. import java.util.List;

  23. import org.openspcoop2.pdd.timers.TimerException;
  24. import org.openspcoop2.utils.serialization.IDeserializer;
  25. import org.openspcoop2.utils.serialization.SerializationConfig;
  26. import org.openspcoop2.utils.serialization.SerializationFactory;
  27. import org.openspcoop2.utils.serialization.SerializationFactory.SERIALIZATION_TYPE;

  28. /**    
  29.  * TimerGestoreChiaviPDNDEvents
  30.  *
  31.  * @author Poli Andrea (poli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class TimerGestoreChiaviPDNDEvents {

  36.     /** Esempi:
  37.      * Events:
  38.       type: object
  39.       properties:
  40.         lastEventId:
  41.           type: integer
  42.           format: int64
  43.         events:
  44.           type: array
  45.           items:
  46.             $ref: '#/components/schemas/Event'
  47.       required:
  48.         - events
  49.        
  50.       {"events":[...]}
  51.       Se non presenti: {"events":[]}
  52.     */
  53.     // (type:integer format:int64) This value is also used to sort the events in chronological order
  54.     private long lastEventId;
  55.     // events
  56.     private List<TimerGestoreChiaviPDNDEvent> events = new ArrayList<>();
  57.    
  58.    
  59.     public long getLastEventId() {
  60.         return this.lastEventId;
  61.     }
  62.     public void setLastEventId(long lastEventId) {
  63.         this.lastEventId = lastEventId;
  64.     }
  65.          
  66.     public List<TimerGestoreChiaviPDNDEvent> getEvents() {
  67.         return this.events;
  68.     }
  69.     public void setEvents(List<TimerGestoreChiaviPDNDEvent> events) {
  70.         this.events = events;
  71.     }  
  72.     public TimerGestoreChiaviPDNDEvents addEventsItem(TimerGestoreChiaviPDNDEvent eventsItem) {
  73.         this.events.add(eventsItem);
  74.         return this;
  75.     }
  76.    
  77.     public static TimerGestoreChiaviPDNDEvents toEvents(String json) throws TimerException {
  78.         try {
  79.             IDeserializer jsonJacksonDeserializer = SerializationFactory.getDeserializer(SERIALIZATION_TYPE.JSON_JACKSON, new SerializationConfig());
  80.             return (TimerGestoreChiaviPDNDEvents) jsonJacksonDeserializer.getObject(json, TimerGestoreChiaviPDNDEvents.class);
  81.         }catch(Exception e) {
  82.             throw new TimerException(e.getMessage(),e);
  83.         }
  84.     }
  85. }