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.reference;
017
018import java.util.ArrayList;
019import java.util.List;
020
021import javax.xml.bind.annotation.XmlAccessType;
022import javax.xml.bind.annotation.XmlAccessorType;
023import javax.xml.bind.annotation.XmlElementRef;
024import javax.xml.bind.annotation.XmlRootElement;
025
026import core.tut.pori.http.ResponseData;
027import service.tut.pori.apilta.alerts.datatypes.Alert;
028import service.tut.pori.apilta.alerts.datatypes.AlertList;
029
030/**
031 * Response example
032 * 
033 */
034@XmlRootElement(name=Definitions.ELEMENT_EXAMPLE)
035@XmlAccessorType(XmlAccessType.NONE)
036public class Example extends ResponseData {
037  @XmlElementRef
038  private Alert _alert = null;
039  @XmlElementRef
040  private AlertList _alertList = null;
041
042  /**
043   * overridden to gather the real classes required for serialization
044   */
045  @Override
046  public Class<?>[] getDataClasses() {
047    List<Class<?>> classes = new ArrayList<>();
048    classes.add(getClass());
049    if(_alert != null){
050      classes.add(_alert.getClass());
051    }
052    if(_alertList != null){
053      classes.add(_alertList.getClass());
054    }
055    return classes.toArray(new Class<?>[classes.size()]);
056  }
057
058  /**
059   * @return the alert
060   */
061  public Alert getAlert() {
062    return _alert;
063  }
064
065  /**
066   * @param alert the alert to set
067   */
068  public void setAlert(Alert alert) {
069    _alert = alert;
070  }
071
072  /**
073   * @return the alertList
074   */
075  public AlertList getAlertList() {
076    return _alertList;
077  }
078
079  /**
080   * @param alertList the alertList to set
081   */
082  public void setAlertList(AlertList alertList) {
083    _alertList = alertList;
084  }
085}