001/** 002 * Copyright 2016 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package service.tut.pori.apilta.alerts.datatypes; 017 018import java.util.List; 019 020import javax.xml.bind.annotation.XmlAccessType; 021import javax.xml.bind.annotation.XmlAccessorType; 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlRootElement; 024 025import core.tut.pori.http.ResponseData; 026 027/** 028 * list of alerts 029 * 030 */ 031@XmlRootElement(name=Definitions.ELEMENT_ALERT_LIST) 032@XmlAccessorType(value=XmlAccessType.NONE) 033public class AlertList extends ResponseData { 034 @XmlElement(name = Definitions.ELEMENT_ALERT) 035 private List<Alert> _alerts = null; 036 037 /** 038 * @return the alerts 039 * @see #setAlerts(List) 040 */ 041 public List<Alert> getAlerts() { 042 return _alerts; 043 } 044 045 /** 046 * @param alerts the alerts to set 047 * @see #getAlerts() 048 */ 049 public void setAlerts(List<Alert> alerts) { 050 _alerts = alerts; 051 } 052 053 /** 054 * for sub-classing, use the static 055 * 056 * @return true if empty 057 * @see #isEmpty(AlertList) 058 */ 059 protected boolean isEmpty() { 060 return (_alerts == null || _alerts.isEmpty()); 061 } 062 063 /** 064 * 065 * @param list 066 * @return true if the list is null or empty 067 */ 068 public static boolean isEmpty(AlertList list) { 069 if(list == null){ 070 return true; 071 }else{ 072 return list.isEmpty(); 073 } 074 } 075}