001/** 002 * Copyright 2018 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.shock.datatypes; 017 018import java.util.List; 019 020import javax.xml.bind.annotation.XmlAccessType; 021import javax.xml.bind.annotation.XmlAccessorType; 022import javax.xml.bind.annotation.XmlElementRef; 023import javax.xml.bind.annotation.XmlRootElement; 024 025import core.tut.pori.http.ResponseData; 026 027/** 028 * 029 * 030 */ 031@XmlRootElement(name=Definitions.ELEMENT_SHOCK_HIGHLIGHT_LIST) 032@XmlAccessorType(XmlAccessType.NONE) 033public class ShockHighlightList extends ResponseData { 034 @XmlElementRef 035 private List<ShockHighlight> _shockHighlights = null; 036 037 /** 038 * @return the shockHighlights 039 */ 040 public List<ShockHighlight> getShockHighlights() { 041 return _shockHighlights; 042 } 043 044 /** 045 * @param shockHighlights the shockHighlights to set 046 */ 047 public void setShockHighlights(List<ShockHighlight> shockHighlights) { 048 _shockHighlights = shockHighlights; 049 } 050 051 /** 052 * for sub-classing, use the static 053 * 054 * @return true if list is empty 055 */ 056 protected boolean isEmpty() { 057 return (_shockHighlights == null || _shockHighlights.isEmpty()); 058 } 059 060 /** 061 * 062 * @param list 063 * @return true if the list is null or empty 064 */ 065 public static boolean isEmpty(ShockHighlightList list) { 066 return (list == null || list.isEmpty()); 067 } 068 069 /** 070 * 071 * @param highlights 072 * @return return list object containing the given list or null if null or empty list was passed 073 */ 074 public static ShockHighlightList getShockMeasurementList(List<ShockHighlight> highlights) { 075 if(highlights == null || highlights.isEmpty()) { 076 return null; 077 } 078 ShockHighlightList list = new ShockHighlightList(); 079 list._shockHighlights = highlights; 080 return list; 081 } 082}