Java 17 features (A-G) (#15516)

- add missing @override
- Java style array syntax
- remove redundant modifiers
- always move String constants to left side in comparisons
- simplify lambda expressions and return statements
- use replace instead of replaceAll w/o regex
- instanceof matching and multiline strings

Signed-off-by: Holger Friedrich <mail@holger-friedrich.de>
This commit is contained in:
Holger Friedrich
2023-09-05 22:30:16 +02:00
committed by GitHub
parent a0dc5c05f2
commit cf10b3e9c7
486 changed files with 2053 additions and 1955 deletions

View File

@@ -87,8 +87,8 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
@Override
public void setThingHandler(@NonNullByDefault({}) ThingHandler handler) {
if (handler instanceof AVMFritzBaseBridgeHandler) {
bridgeHandler = (AVMFritzBaseBridgeHandler) handler;
if (handler instanceof AVMFritzBaseBridgeHandler baseBridgeHandler) {
bridgeHandler = baseBridgeHandler;
}
}
@@ -128,9 +128,9 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
properties.put(PRODUCT_NAME, device.getProductName());
properties.put(PROPERTY_SERIAL_NUMBER, device.getIdentifier());
properties.put(PROPERTY_FIRMWARE_VERSION, device.getFirmwareVersion());
if (device instanceof GroupModel && ((GroupModel) device).getGroupinfo() != null) {
properties.put(PROPERTY_MASTER, ((GroupModel) device).getGroupinfo().getMasterdeviceid());
properties.put(PROPERTY_MEMBERS, ((GroupModel) device).getGroupinfo().getMembers());
if (device instanceof GroupModel model && model.getGroupinfo() != null) {
properties.put(PROPERTY_MASTER, model.getGroupinfo().getMasterdeviceid());
properties.put(PROPERTY_MEMBERS, model.getGroupinfo().getMembers());
}
DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(thingUID).withProperties(properties)

View File

@@ -17,9 +17,9 @@ import static org.openhab.binding.avmfritz.internal.dto.DeviceModel.ETSUnitInfoM
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@@ -172,21 +172,21 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
@Override
public void childHandlerInitialized(ThingHandler childHandler, Thing childThing) {
if (childHandler instanceof FritzAhaStatusListener) {
registerStatusListener((FritzAhaStatusListener) childHandler);
if (childHandler instanceof FritzAhaStatusListener listener) {
registerStatusListener(listener);
}
}
@Override
public void childHandlerDisposed(ThingHandler childHandler, Thing childThing) {
if (childHandler instanceof FritzAhaStatusListener) {
unregisterStatusListener((FritzAhaStatusListener) childHandler);
if (childHandler instanceof FritzAhaStatusListener listener) {
unregisterStatusListener(listener);
}
}
@Override
public Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(AVMFritzDiscoveryService.class);
return Set.of(AVMFritzDiscoveryService.class);
}
public boolean registerStatusListener(FritzAhaStatusListener listener) {
@@ -327,7 +327,7 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
} else if (device.isSwitchableOutlet()) {
return GROUP_SWITCH;
}
} else if (device instanceof DeviceModel && device.isHANFUNUnit()) {
} else if (device instanceof DeviceModel deviceModel && device.isHANFUNUnit()) {
if (device.isHANFUNBlinds()) {
return DEVICE_HAN_FUN_BLINDS;
} else if (device.isColorLight()) {
@@ -335,8 +335,7 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
} else if (device.isDimmableLight()) {
return DEVICE_HAN_FUN_DIMMABLE_BULB;
}
List<String> interfaces = Arrays
.asList(((DeviceModel) device).getEtsiunitinfo().getInterfaces().split(","));
List<String> interfaces = Arrays.asList(deviceModel.getEtsiunitinfo().getInterfaces().split(","));
if (interfaces.contains(HAN_FUN_INTERFACE_ALERT)) {
return DEVICE_HAN_FUN_CONTACT;
} else if (interfaces.contains(HAN_FUN_INTERFACE_SIMPLE_BUTTON)) {

View File

@@ -187,8 +187,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (device.isHeatingThermostat()) {
updateHeatingThermostat(device.getHkr());
}
if (device instanceof DeviceModel) {
DeviceModel deviceModel = (DeviceModel) device;
if (device instanceof DeviceModel deviceModel) {
if (deviceModel.isTemperatureSensor()) {
updateTemperatureSensor(deviceModel.getTemperature());
}
@@ -497,13 +496,12 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
case CHANNEL_COLOR:
case CHANNEL_BRIGHTNESS:
BigDecimal brightness = null;
if (command instanceof HSBType) {
HSBType hsbType = (HSBType) command;
brightness = hsbType.getBrightness().toBigDecimal();
fritzBox.setUnmappedHueAndSaturation(ain, hsbType.getHue().intValue(),
ColorControlModel.fromPercent(hsbType.getSaturation()), 0);
} else if (command instanceof PercentType) {
brightness = ((PercentType) command).toBigDecimal();
if (command instanceof HSBType hsbCommand) {
brightness = hsbCommand.getBrightness().toBigDecimal();
fritzBox.setUnmappedHueAndSaturation(ain, hsbCommand.getHue().intValue(),
ColorControlModel.fromPercent(hsbCommand.getSaturation()), 0);
} else if (command instanceof PercentType brightnessPercent) {
brightness = brightnessPercent.toBigDecimal();
} else if (command instanceof OnOffType) {
fritzBox.setSwitch(ain, OnOffType.ON.equals(command));
} else if (command instanceof IncreaseDecreaseType) {
@@ -525,8 +523,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
break;
case CHANNEL_COLORTEMPERATURE:
BigDecimal colorTemperaturePct = null;
if (command instanceof PercentType) {
colorTemperaturePct = ((PercentType) command).toBigDecimal();
if (command instanceof PercentType percentCommand) {
colorTemperaturePct = percentCommand.toBigDecimal();
}
if (colorTemperaturePct != null) {
int pct = colorTemperaturePct.intValue();
@@ -540,13 +538,13 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
break;
case CHANNEL_COLORTEMPERATURE_ABS:
BigDecimal colorTemperature = null;
if (command instanceof QuantityType) {
QuantityType<?> convertedCommand = ((QuantityType<?>) command).toInvertibleUnit(Units.KELVIN);
if (command instanceof QuantityType quantityCommand) {
QuantityType<?> convertedCommand = quantityCommand.toInvertibleUnit(Units.KELVIN);
if (convertedCommand != null) {
colorTemperature = convertedCommand.toBigDecimal();
}
} else if (command instanceof DecimalType) {
colorTemperature = ((DecimalType) command).toBigDecimal();
} else if (command instanceof DecimalType decimalCommand) {
colorTemperature = decimalCommand.toBigDecimal();
}
if (colorTemperature != null) {
fritzBox.setColorTemperature(ain, colorTemperature.intValue(), 0);
@@ -554,9 +552,9 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
break;
case CHANNEL_SETTEMP:
BigDecimal temperature = null;
if (command instanceof DecimalType) {
temperature = normalizeCelsius(((DecimalType) command).toBigDecimal());
} else if (command instanceof QuantityType) {
if (command instanceof DecimalType decimalCommand) {
temperature = normalizeCelsius(decimalCommand.toBigDecimal());
} else if (command instanceof QuantityType quantityCommand) {
@SuppressWarnings("unchecked")
QuantityType<Temperature> convertedCommand = ((QuantityType<Temperature>) command)
.toUnit(SIUnits.CELSIUS);
@@ -564,7 +562,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
temperature = normalizeCelsius(convertedCommand.toBigDecimal());
} else {
logger.warn("Unable to convert unit from '{}' to '{}'. Skipping command.",
((QuantityType<?>) command).getUnit(), SIUnits.CELSIUS);
quantityCommand.getUnit(), SIUnits.CELSIUS);
}
} else if (command instanceof IncreaseDecreaseType) {
temperature = currentDevice.getHkr().getTsoll();
@@ -615,22 +613,20 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
}
break;
case CHANNEL_ROLLERSHUTTER:
if (command instanceof StopMoveType) {
StopMoveType rollershutterCommand = (StopMoveType) command;
if (command instanceof StopMoveType rollershutterCommand) {
if (StopMoveType.STOP.equals(rollershutterCommand)) {
fritzBox.setBlind(ain, BlindCommand.STOP);
} else {
logger.debug("Received unknown rollershutter StopMove command MOVE");
}
} else if (command instanceof UpDownType) {
UpDownType rollershutterCommand = (UpDownType) command;
} else if (command instanceof UpDownType rollershutterCommand) {
if (UpDownType.UP.equals(rollershutterCommand)) {
fritzBox.setBlind(ain, BlindCommand.OPEN);
} else {
fritzBox.setBlind(ain, BlindCommand.CLOSE);
}
} else if (command instanceof PercentType) {
BigDecimal levelPercentage = ((PercentType) command).toBigDecimal();
} else if (command instanceof PercentType percentCommand) {
BigDecimal levelPercentage = percentCommand.toBigDecimal();
fritzBox.setLevelPercentage(ain, levelPercentage);
} else {
logger.debug("Received unknown rollershutter command type '{}'", command.toString());
@@ -686,8 +682,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
Bridge bridge = getBridge();
if (bridge != null) {
BridgeHandler handler = bridge.getHandler();
if (handler instanceof AVMFritzBaseBridgeHandler) {
return ((AVMFritzBaseBridgeHandler) handler).getWebInterface();
if (handler instanceof AVMFritzBaseBridgeHandler bridgeHandler) {
return bridgeHandler.getWebInterface();
}
}
return null;
@@ -700,8 +696,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
Bridge bridge = getBridge();
if (bridge != null) {
BridgeHandler handler = bridge.getHandler();
if (handler instanceof AVMFritzBaseBridgeHandler) {
((AVMFritzBaseBridgeHandler) handler).handleRefreshCommand();
if (handler instanceof AVMFritzBaseBridgeHandler bridgeHandler) {
bridgeHandler.handleRefreshCommand();
}
}
}

View File

@@ -78,8 +78,7 @@ public class AVMFritzButtonHandler extends DeviceHandler {
if (thing.getUID().equals(thingUID)) {
super.onDeviceUpdated(thingUID, device);
if (device instanceof DeviceModel) {
DeviceModel deviceModel = (DeviceModel) device;
if (device instanceof DeviceModel deviceModel) {
if (deviceModel.isHANFUNButton()) {
updateHANFUNButton(deviceModel.getButtons());
}

View File

@@ -13,7 +13,7 @@
package org.openhab.binding.avmfritz.internal.handler;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.avmfritz.internal.actions.AVMFritzHeatingActions;
@@ -30,7 +30,7 @@ public interface AVMFritzHeatingActionsHandler extends ThingHandler {
@Override
default Collection<Class<? extends ThingHandlerService>> getServices() {
return Collections.singleton(AVMFritzHeatingActions.class);
return Set.of(AVMFritzHeatingActions.class);
}
/**

View File

@@ -35,8 +35,7 @@ public class GroupHandler extends AVMFritzBaseThingHandler {
@Override
protected void updateProperties(AVMFritzBaseModel device, Map<String, String> editProperties) {
if (device instanceof GroupModel) {
GroupModel groupModel = (GroupModel) device;
if (device instanceof GroupModel groupModel) {
if (groupModel.getGroupinfo() != null) {
editProperties.put(PROPERTY_MASTER, groupModel.getGroupinfo().getMasterdeviceid());
editProperties.put(PROPERTY_MEMBERS, groupModel.getGroupinfo().getMembers());

View File

@@ -45,72 +45,74 @@ public class AVMFritzDeviceListModelTest {
public void setUp() throws JAXBException, XMLStreamException {
//@formatter:off
final String xml =
"<devicelist version=\"1\">"
+ "<group identifier=\"F0:A3:7F-900\" id=\"20000\" functionbitmask=\"6784\" fwversion=\"1.0\" manufacturer=\"AVM\" productname=\"\"><present>1</present><name>Schlafzimmer</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><groupinfo><masterdeviceid>17</masterdeviceid><members>17,18</members></groupinfo></group>"
+ "<group identifier=\"F0:A3:7F-901\" id=\"20001\" functionbitmask=\"4160\" fwversion=\"1.0\" manufacturer=\"AVM\" productname=\"\"><present>1</present><name>Schlafzimmer</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr><groupinfo><masterdeviceid>0</masterdeviceid><members>20,21,22</members></groupinfo></group>"
+ "<device identifier=\"08761 0000434\" id=\"17\" functionbitmask=\"35712\" fwversion=\"03.83\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 200\"><present>1</present><name>FRITZ!DECT 200 #1</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>"
+ "<device identifier=\"08761 0000438\" id=\"18\" functionbitmask=\"35712\" fwversion=\"03.83\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 210\"><present>1</present><name>FRITZ!DECT 210 #8</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>"
+ "<device identifier=\"08761 0000437\" id=\"20\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 300\"><present>0</present><name>FRITZ!DECT 300 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
+ "<device identifier=\"08761 0000436\" id=\"21\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 301\"><present>0</present><name>FRITZ!DECT 301 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
+ "<device identifier=\"08761 0000435\" id=\"22\" functionbitmask=\"320\" fwversion=\"03.50\" manufacturer=\"AVM\" productname=\"Comet DECT\"><present>0</present><name>Comet DECT #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>"
+ "<device identifier=\"5C:49:79:F0:A3:84\" id=\"30\" functionbitmask=\"640\" fwversion=\"06.92\" manufacturer=\"AVM\" productname=\"FRITZ!Powerline 546E\"><present>1</present><name>FRITZ!Powerline 546E #1</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>1</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter></device>"
+ "<device identifier=\"08761 0000439\" id=\"40\" functionbitmask=\"1280\" fwversion=\"03.86\" manufacturer=\"AVM\" productname=\"FRITZ!DECT Repeater 100\"><present>1</present><name>FRITZ!DECT Repeater 100 #5</name><temperature><celsius>230</celsius><offset>0</offset></temperature></device>"
+ "<device identifier=\"11934 0059978-1\" id=\"2000\" functionbitmask=\"8208\" fwversion=\"0.0\" manufacturer=\"0x0feb\" productname=\"HAN-FUN\"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>514</unittype><interfaces>256</interfaces></etsiunitinfo><alert><state>1</state></alert></device>"
+ "<device identifier=\"11934 0059979-1\" id=\"2001\" functionbitmask=\"8200\" fwversion=\"0.0\" manufacturer=\"0x0feb\" productname=\"HAN-FUN\"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>412</etsideviceid><unittype>273</unittype><interfaces>772</interfaces></etsiunitinfo><button><lastpressedtimestamp>1529590797</lastpressedtimestamp></button></device>"
+ "<device identifier=\"13096 0007307\" id=\"29\" functionbitmask=\"32\" fwversion=\"04.90\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 400\"><present>1</present><name>FRITZ!DECT 400 #14</name><battery>100</battery><batterylow>0</batterylow><button identifier=\"13096 0007307-0\" id=\"5000\"><name>FRITZ!DECT 400 #14: kurz</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007307-9\" id=\"5001\"><name>FRITZ!DECT 400 #14: lang</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>"
+ "<device identifier=\"13096 0007308\" id=\"30\" functionbitmask=\"1048864\" fwversion=\"05.10\" manufacturer=\"AVM\" productname=\"FRITZ!DECT 440\"><present>1</present><name>FRITZ!DECT 440 #15</name><temperature><celsius>230</celsius><offset>0</offset></temperature><humidity><rel_humidity>43</rel_humidity></humidity><battery>100</battery><batterylow>0</batterylow><button identifier=\"13096 0007308-1\" id=\"5000\"><name>FRITZ!DECT 440 #15: Oben rechts</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007308-3\" id=\"5001\"><name>FRITZ!DECT 440 #15: Unten rechts</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button><button identifier=\"13096 0007308-5\" id=\"5002\"><name>FRITZ!DECT 440 #15: Unten links</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier=\"13096 0007308-7\" id=\"5003\"><name>FRITZ!DECT 440 #15: Oben links</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>"
+ "<device identifier=\"14276 0503450-1\" id=\"2000\" functionbitmask=\"335888\" fwversion=\"0.0\" manufacturer=\"0x37c4\" productname=\"Rollotron 1213\"><present>1</present><txbusy>0</txbusy><name>Rollotron 1213 #1</name><blind><endpositionsset>1</endpositionsset><mode>manuell</mode></blind><levelcontrol><level>26</level><levelpercentage>10</levelpercentage></levelcontrol><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>281</unittype><interfaces>256,513,516,517</interfaces></etsiunitinfo><alert><state>0</state><lastalertchgtimestamp></lastalertchgtimestamp></alert></device>"
+ "<device identifier=\"11324 0824499-1\" id=\"2002\" functionbitmask=\"40960\" fwversion=\"0.0\" manufacturer=\"0x2c3c\" productname=\"HAN-FUN\">\n"
+ " <present>1</present>\n"
+ " <txbusy>0</txbusy>\n"
+ " <name>Steckdose innen</name>\n"
+ " <simpleonoff>\n"
+ " <state>0</state>\n"
+ " </simpleonoff>\n"
+ " <etsiunitinfo>\n"
+ " <etsideviceid>408</etsideviceid>\n"
+ " <unittype>263</unittype>\n"
+ " <interfaces>512,768</interfaces>\n"
+ " </etsiunitinfo>\n"
+ "</device>"
+ "<device identifier=\"11324 0584796-1\" id=\"2001\" functionbitmask=\"40960\" fwversion=\"0.0\" manufacturer=\"0x2c3c\" productname=\"HAN-FUN\">\n"
+ " <present>1</present>\n"
+ " <txbusy>0</txbusy>\n"
+ " <name>Steckdose außen</name>\n"
+ " <simpleonoff>\n"
+ " <state>0</state>\n"
+ " </simpleonoff>\n"
+ " <etsiunitinfo>\n"
+ " <etsideviceid>407</etsideviceid>\n"
+ " <unittype>262</unittype>\n"
+ " <interfaces>512</interfaces>\n"
+ " </etsiunitinfo>\n"
+ "</device>"
+ "<device identifier=\"12701 0027533-1\" id=\"2002\" functionbitmask=\"237572\" fwversion=\"0.0\" manufacturer=\"0x319d\" productname=\"HAN-FUN\">\n"
+ " <present>0</present>\n"
+ " <txbusy>0</txbusy>\n"
+ " <name>SmartHome LED-Lampe #1</name>\n"
+ " <simpleonoff>\n"
+ " <state>0</state>\n"
+ " </simpleonoff>\n"
+ " <levelcontrol>\n"
+ " <level>26</level>\n"
+ " <levelpercentage>10</levelpercentage>\n"
+ " </levelcontrol>\n"
+ " <colorcontrol supported_modes=\"0\" current_mode=\"\" fullcolorsupport=\"0\" mapped=\"0\">\n"
+ " <hue>254</hue>\n"
+ " <saturation>100</saturation>\n"
+ " <unmapped_hue></unmapped_hue>\n"
+ " <unmapped_saturation></unmapped_saturation>\n"
+ " <temperature>2700</temperature>\n"
+ " </colorcontrol>\n"
+ " <etsiunitinfo>\n"
+ " <etsideviceid>407</etsideviceid>\n"
+ " <unittype>278</unittype>\n"
+ " <interfaces>512,514,513</interfaces>\n"
+ " </etsiunitinfo>\n"
+ "</device>" +
"</devicelist>";
"""
<devicelist version="1">\
<group identifier="F0:A3:7F-900" id="20000" functionbitmask="6784" fwversion="1.0" manufacturer="AVM" productname=""><present>1</present><name>Schlafzimmer</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><groupinfo><masterdeviceid>17</masterdeviceid><members>17,18</members></groupinfo></group>\
<group identifier="F0:A3:7F-901" id="20001" functionbitmask="4160" fwversion="1.0" manufacturer="AVM" productname=""><present>1</present><name>Schlafzimmer</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr><groupinfo><masterdeviceid>0</masterdeviceid><members>20,21,22</members></groupinfo></group>\
<device identifier="08761 0000434" id="17" functionbitmask="35712" fwversion="03.83" manufacturer="AVM" productname="FRITZ!DECT 200"><present>1</present><name>FRITZ!DECT 200 #1</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>\
<device identifier="08761 0000438" id="18" functionbitmask="35712" fwversion="03.83" manufacturer="AVM" productname="FRITZ!DECT 210"><present>1</present><name>FRITZ!DECT 210 #8</name><switch><state>1</state><mode>manuell</mode><lock>0</lock><devicelock>0</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter><temperature><celsius>255</celsius><offset>0</offset></temperature></device>\
<device identifier="08761 0000437" id="20" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="FRITZ!DECT 300"><present>0</present><name>FRITZ!DECT 300 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
<device identifier="08761 0000436" id="21" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="FRITZ!DECT 301"><present>0</present><name>FRITZ!DECT 301 #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
<device identifier="08761 0000435" id="22" functionbitmask="320" fwversion="03.50" manufacturer="AVM" productname="Comet DECT"><present>0</present><name>Comet DECT #1</name><temperature><celsius>220</celsius><offset>-10</offset></temperature><hkr><tist>44</tist><tsoll>42</tsoll><absenk>28</absenk><komfort>42</komfort><lock>1</lock><devicelock>1</devicelock><errorcode>0</errorcode><windowopenactiv>0</windowopenactiv><windowopenactiveendtime>0</windowopenactiveendtime><boostactive>0</boostactive><boostactiveendtime>0</boostactiveendtime><batterylow>0</batterylow><battery>100</battery><nextchange><endperiod>1484341200</endperiod><tchange>28</tchange></nextchange></hkr></device>\
<device identifier="5C:49:79:F0:A3:84" id="30" functionbitmask="640" fwversion="06.92" manufacturer="AVM" productname="FRITZ!Powerline 546E"><present>1</present><name>FRITZ!Powerline 546E #1</name><switch><state>0</state><mode>manuell</mode><lock>0</lock><devicelock>1</devicelock></switch><powermeter><voltage>230051</voltage><power>0</power><energy>2087</energy></powermeter></device>\
<device identifier="08761 0000439" id="40" functionbitmask="1280" fwversion="03.86" manufacturer="AVM" productname="FRITZ!DECT Repeater 100"><present>1</present><name>FRITZ!DECT Repeater 100 #5</name><temperature><celsius>230</celsius><offset>0</offset></temperature></device>\
<device identifier="11934 0059978-1" id="2000" functionbitmask="8208" fwversion="0.0" manufacturer="0x0feb" productname="HAN-FUN"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>514</unittype><interfaces>256</interfaces></etsiunitinfo><alert><state>1</state></alert></device>\
<device identifier="11934 0059979-1" id="2001" functionbitmask="8200" fwversion="0.0" manufacturer="0x0feb" productname="HAN-FUN"><present>0</present><name>HAN-FUN #2: Unit #2</name><etsiunitinfo><etsideviceid>412</etsideviceid><unittype>273</unittype><interfaces>772</interfaces></etsiunitinfo><button><lastpressedtimestamp>1529590797</lastpressedtimestamp></button></device>\
<device identifier="13096 0007307" id="29" functionbitmask="32" fwversion="04.90" manufacturer="AVM" productname="FRITZ!DECT 400"><present>1</present><name>FRITZ!DECT 400 #14</name><battery>100</battery><batterylow>0</batterylow><button identifier="13096 0007307-0" id="5000"><name>FRITZ!DECT 400 #14: kurz</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007307-9" id="5001"><name>FRITZ!DECT 400 #14: lang</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>\
<device identifier="13096 0007308" id="30" functionbitmask="1048864" fwversion="05.10" manufacturer="AVM" productname="FRITZ!DECT 440"><present>1</present><name>FRITZ!DECT 440 #15</name><temperature><celsius>230</celsius><offset>0</offset></temperature><humidity><rel_humidity>43</rel_humidity></humidity><battery>100</battery><batterylow>0</batterylow><button identifier="13096 0007308-1" id="5000"><name>FRITZ!DECT 440 #15: Oben rechts</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007308-3" id="5001"><name>FRITZ!DECT 440 #15: Unten rechts</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button><button identifier="13096 0007308-5" id="5002"><name>FRITZ!DECT 440 #15: Unten links</name><lastpressedtimestamp>1549195586</lastpressedtimestamp></button><button identifier="13096 0007308-7" id="5003"><name>FRITZ!DECT 440 #15: Oben links</name><lastpressedtimestamp>1549195595</lastpressedtimestamp></button></device>\
<device identifier="14276 0503450-1" id="2000" functionbitmask="335888" fwversion="0.0" manufacturer="0x37c4" productname="Rollotron 1213"><present>1</present><txbusy>0</txbusy><name>Rollotron 1213 #1</name><blind><endpositionsset>1</endpositionsset><mode>manuell</mode></blind><levelcontrol><level>26</level><levelpercentage>10</levelpercentage></levelcontrol><etsiunitinfo><etsideviceid>406</etsideviceid><unittype>281</unittype><interfaces>256,513,516,517</interfaces></etsiunitinfo><alert><state>0</state><lastalertchgtimestamp></lastalertchgtimestamp></alert></device>\
<device identifier="11324 0824499-1" id="2002" functionbitmask="40960" fwversion="0.0" manufacturer="0x2c3c" productname="HAN-FUN">
<present>1</present>
<txbusy>0</txbusy>
<name>Steckdose innen</name>
<simpleonoff>
<state>0</state>
</simpleonoff>
<etsiunitinfo>
<etsideviceid>408</etsideviceid>
<unittype>263</unittype>
<interfaces>512,768</interfaces>
</etsiunitinfo>
</device>\
<device identifier="11324 0584796-1" id="2001" functionbitmask="40960" fwversion="0.0" manufacturer="0x2c3c" productname="HAN-FUN">
<present>1</present>
<txbusy>0</txbusy>
<name>Steckdose außen</name>
<simpleonoff>
<state>0</state>
</simpleonoff>
<etsiunitinfo>
<etsideviceid>407</etsideviceid>
<unittype>262</unittype>
<interfaces>512</interfaces>
</etsiunitinfo>
</device>\
<device identifier="12701 0027533-1" id="2002" functionbitmask="237572" fwversion="0.0" manufacturer="0x319d" productname="HAN-FUN">
<present>0</present>
<txbusy>0</txbusy>
<name>SmartHome LED-Lampe #1</name>
<simpleonoff>
<state>0</state>
</simpleonoff>
<levelcontrol>
<level>26</level>
<levelpercentage>10</levelpercentage>
</levelcontrol>
<colorcontrol supported_modes="0" current_mode="" fullcolorsupport="0" mapped="0">
<hue>254</hue>
<saturation>100</saturation>
<unmapped_hue></unmapped_hue>
<unmapped_saturation></unmapped_saturation>
<temperature>2700</temperature>
</colorcontrol>
<etsiunitinfo>
<etsideviceid>407</etsideviceid>
<unittype>278</unittype>
<interfaces>512,514,513</interfaces>
</etsiunitinfo>
</device>\
</devicelist>\
""";
//@formatter:on
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_DEVICES.createUnmarshaller();

View File

@@ -44,10 +44,12 @@ public class AVMFritzTemplateListModelTest {
public void setUp() throws JAXBException, XMLStreamException {
//@formatter:off
String xml =
"<templatelist version=\"1\">" +
"<template identifier=\"tmpXXXXX-39DC738C5\" id=\"30103\" functionbitmask=\"6784\" applymask=\"64\"><name>Test template #1</name><devices><device identifier=\"YY:5D:AA-900\" /><device identifier=\"XX:5D:AA-900\" /></devices><applymask><relay_automatic /></applymask></template>" +
"<template identifier=\"tmpXXXXX-39722FC0F\" id=\"30003\" functionbitmask=\"6784\" applymask=\"64\"><name>Test template #2</name><devices><device identifier=\"YY:5D:AA-900\" /></devices><applymask><relay_automatic /></applymask></template>" +
"</templatelist>";
"""
<templatelist version="1">\
<template identifier="tmpXXXXX-39DC738C5" id="30103" functionbitmask="6784" applymask="64"><name>Test template #1</name><devices><device identifier="YY:5D:AA-900" /><device identifier="XX:5D:AA-900" /></devices><applymask><relay_automatic /></applymask></template>\
<template identifier="tmpXXXXX-39722FC0F" id="30003" functionbitmask="6784" applymask="64"><name>Test template #2</name><devices><device identifier="YY:5D:AA-900" /></devices><applymask><relay_automatic /></applymask></template>\
</templatelist>\
""";
//@formatter:on
XMLStreamReader xsr = JAXBUtils.XMLINPUTFACTORY.createXMLStreamReader(new StringReader(xml));
Unmarshaller u = JAXBUtils.JAXBCONTEXT_TEMPLATES.createUnmarshaller();