| /* |
| ******************************************************************************** |
| * Copyright (c) 2014, 2018 Orange. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| ******************************************************************************** |
| |
| Device : DeviceThermometer |
| |
| A thermometer is a device that can be used to check, for example, the body or other temperatures. |
| |
| Created: 2018-06-29 17:19:55 |
| */ |
| |
| package org.eclipse.om2m.commons.resource.flexcontainerspec; |
| |
| import javax.xml.bind.annotation.XmlAccessType; |
| import javax.xml.bind.annotation.XmlAccessorType; |
| import javax.xml.bind.annotation.XmlElement; |
| import javax.xml.bind.annotation.XmlRootElement; |
| import javax.xml.bind.annotation.XmlType; |
| |
| import org.eclipse.om2m.commons.resource.AbstractFlexContainer; |
| |
| @XmlRootElement(name = DeviceThermometerFlexContainer.SHORT_NAME, namespace = "http://www.onem2m.org/xml/protocols/homedomain") |
| @XmlAccessorType(XmlAccessType.FIELD) |
| @XmlType(name = DeviceThermometerFlexContainer.SHORT_NAME, namespace = "http://www.onem2m.org/xml/protocols/homedomain") |
| public class DeviceThermometerFlexContainer extends AbstractFlexContainer { |
| |
| public static final String LONG_NAME = "deviceThermometer"; |
| public static final String SHORT_NAME = "devTr"; |
| |
| public DeviceThermometerFlexContainer () { |
| setContainerDefinition("org.onem2m.home.device." + DeviceThermometerFlexContainer.LONG_NAME); |
| setLongName(LONG_NAME); |
| setShortName(SHORT_NAME); |
| } |
| |
| public void finalizeSerialization() { |
| getTemperature(); |
| getBattery(); |
| } |
| |
| public void finalizeDeserialization() { |
| if (this.temperature != null) { |
| setTemperature(this.temperature); |
| } |
| if (this.battery != null) { |
| setBattery(this.battery); |
| } |
| } |
| |
| @XmlElement(name=TemperatureFlexContainer.SHORT_NAME, required=true, type=TemperatureFlexContainer.class, namespace="http://www.onem2m.org/xml/protocols/homedomain") |
| private TemperatureFlexContainer temperature; |
| |
| public void setTemperature(TemperatureFlexContainer temperature) { |
| this.temperature = temperature; |
| getFlexContainerOrContainerOrSubscription().add(temperature); |
| } |
| |
| public TemperatureFlexContainer getTemperature() { |
| this.temperature = (TemperatureFlexContainer) getResourceByName(TemperatureFlexContainer.SHORT_NAME); |
| return temperature; |
| } |
| |
| @XmlElement(name=BatteryFlexContainer.SHORT_NAME, required=true, type=BatteryFlexContainer.class, namespace="http://www.onem2m.org/xml/protocols/homedomain") |
| private BatteryFlexContainer battery; |
| |
| public void setBattery(BatteryFlexContainer battery) { |
| this.battery = battery; |
| getFlexContainerOrContainerOrSubscription().add(battery); |
| } |
| |
| public BatteryFlexContainer getBattery() { |
| this.battery = (BatteryFlexContainer) getResourceByName(BatteryFlexContainer.SHORT_NAME); |
| return battery; |
| } |
| |
| } |