From ce417086220a897a8e72d005287ec4b1ca585fa2 Mon Sep 17 00:00:00 2001 From: Kai Kreuzer Date: Sat, 18 Feb 2023 15:01:41 +0100 Subject: [PATCH] [lametrictime] Move external library to internal code (#14425) Signed-off-by: Kai Kreuzer --- .../org.openhab.binding.lametrictime/NOTICE | 7 +- .../org.openhab.binding.lametrictime/pom.xml | 12 - .../lametrictime/api/Configuration.java | 162 ------- .../api/cloud/CloudConfiguration.java | 91 ---- .../api/cloud/LaMetricTimeCloud.java | 39 -- .../lametrictime/api/cloud/model/Icon.java | 139 ------ .../api/cloud/model/IconField.java | 34 -- .../api/cloud/model/IconFilter.java | 113 ----- .../api/cloud/model/IconOrder.java | 28 -- .../api/cloud/model/IconType.java | 26 - .../lametrictime/api/cloud/model/Icons.java | 57 --- .../api/cloud/model/IconsMetadata.java | 88 ---- .../lametrictime/api/cloud/model/Thumb.java | 88 ---- .../api/common/impl/GsonGenerator.java | 68 --- .../UpdateActionTypeAdapterFactory.java | 75 --- .../imported/DateTimeTypeAdapter.java | 43 -- .../imported/DurationTypeAdapter.java | 35 -- .../imported/InstantTypeAdapter.java | 35 -- .../imported/JSR310TypeAdapters.java | 109 ----- .../imported/LocalDateTimeTypeAdapter.java | 35 -- .../imported/LocalDateTypeAdapter.java | 35 -- .../imported/LocalTimeTypeAdapter.java | 35 -- .../imported/MonthDayTypeAdapter.java | 35 -- .../imported/OffsetDateTimeTypeAdapter.java | 35 -- .../imported/OffsetTimeTypeAdapter.java | 35 -- .../imported/PeriodTypeAdapter.java | 35 -- .../imported/RuntimeTypeAdapterFactory.java | 420 ---------------- .../imported/TemporalTypeAdapter.java | 69 --- .../imported/YearMonthTypeAdapter.java | 35 -- .../imported/YearTypeAdapter.java | 35 -- .../imported/ZonedDateTimeTypeAdapter.java | 35 -- .../api/impl/AbstractDataIcon.java | 76 --- .../lametrictime/api/impl/DataIcon.java | 37 -- .../lametrictime/api/impl/FileIcon.java | 55 --- .../lametrictime/api/impl/HTTPIcon.java | 47 -- .../lametrictime/api/impl/KeyIcon.java | 34 -- .../api/impl/LaMetricTimeImpl.java | 334 ------------- .../api/local/ApplicationActionException.java | 56 --- .../local/ApplicationActivationException.java | 56 --- .../local/ApplicationNotFoundException.java | 56 --- .../api/local/LaMetricTimeException.java | 77 --- .../api/local/LaMetricTimeLocal.java | 93 ---- .../local/NotificationCreationException.java | 56 --- .../local/NotificationNotFoundException.java | 56 --- .../api/local/UpdateException.java | 56 --- .../lametrictime/api/local/model/Action.java | 122 ----- .../lametrictime/api/local/model/Api.java | 66 --- .../lametrictime/api/local/model/Audio.java | 47 -- .../api/local/model/AudioUpdateResult.java | 58 --- .../local/model/BluetoothUpdateResult.java | 58 --- .../api/local/model/BooleanParameter.java | 65 --- .../lametrictime/api/local/model/Display.java | 142 ------ .../api/local/model/DisplayUpdateResult.java | 58 --- .../lametrictime/api/local/model/Error.java | 47 -- .../lametrictime/api/local/model/Failure.java | 50 -- .../api/local/model/GoalData.java | 179 ------- .../api/local/model/IntegerParameter.java | 65 --- .../lametrictime/api/local/model/Modes.java | 66 --- .../api/local/model/NotificationModel.java | 87 ---- .../api/local/model/NotificationResult.java | 58 --- .../api/local/model/Parameter.java | 54 --- .../api/local/model/Screensaver.java | 85 ---- .../lametrictime/api/local/model/Sound.java | 85 ---- .../api/local/model/StringParameter.java | 84 ---- .../api/local/model/TimeBased.java | 47 -- .../api/local/model/UpdateAction.java | 35 -- .../api/local/model/WhenDark.java | 47 -- .../api/local/model/WidgetUpdates.java | 49 -- .../lametrictime/api/model/ApiValue.java | 31 -- .../lametrictime/api/model/ClockApp.java | 78 --- .../lametrictime/api/model/CoreAction.java | 40 -- .../api/model/CoreApplication.java | 31 -- .../lametrictime/api/model/CoreApps.java | 54 --- .../lametrictime/api/model/CountdownApp.java | 68 --- .../binding/lametrictime/api/model/Icon.java | 21 - .../lametrictime/api/model/RadioApp.java | 53 -- .../lametrictime/api/model/StopwatchApp.java | 47 -- .../lametrictime/api/model/WeatherApp.java | 35 -- .../api/model/enums/BrightnessMode.java | 48 -- .../api/model/enums/DisplayType.java | 50 -- .../api/model/enums/IconType.java | 49 -- .../lametrictime/api/model/enums/IpMode.java | 48 -- .../api/model/enums/Priority.java | 49 -- .../api/model/enums/SoundCategory.java | 48 -- .../api/model/enums/WifiEncryption.java | 50 -- .../authentication/BasicAuthenticator.java | 2 +- .../HttpAuthenticationFeature.java | 2 +- .../HttpAuthenticationFilter.java | 3 +- .../RequestAuthenticationException.java | 2 +- .../ResponseAuthenticationException.java | 2 +- .../api/filter/LoggingFilter.java | 2 +- .../api/AllIntegrationTestsSuite.java | 28 -- .../lametrictime/api/AllUnitTestsSuite.java | 27 -- .../lametrictime/api/impl/FileIconTest.java | 56 --- .../api/local/model/AudioTest.java | 55 --- .../api/local/model/BluetoothTest.java | 80 --- .../api/local/model/GoalDataTest.java | 58 --- .../api/local/model/WidgetTest.java | 73 --- .../api/model/enums/BrightnessModeTest.java | 39 -- .../api/model/enums/DisplayTypeTest.java | 39 -- .../api/model/enums/IconTypeTest.java | 39 -- .../api/model/enums/IpModeTest.java | 39 -- .../api/model/enums/PriorityTest.java | 39 -- .../api/model/enums/SoundCategoryTest.java | 39 -- .../api/model/enums/SoundTest.java | 39 -- .../api/model/enums/WifiEncryptionTest.java | 39 -- .../lametrictime/api/test/AbstractTest.java | 35 -- .../lametrictime/api/test/TestUtil.java | 42 -- .../lametrictime/internal/GsonProvider.java | 23 +- .../LaMetricTimeConfigStatusMessage.java | 3 + .../internal/LaMetricTimeUtil.java | 8 +- .../lametrictime/internal/WidgetRef.java | 3 + .../internal/api/Configuration.java | 140 ++++++ .../internal}/api/LaMetricTime.java | 116 +++-- .../api/cloud/CloudConfiguration.java | 83 ++++ .../internal/api/cloud/LaMetricTimeCloud.java | 40 ++ .../internal/api/cloud/dto/Icon.java | 119 +++++ .../internal/api/cloud/dto/IconField.java | 35 ++ .../internal/api/cloud/dto/IconFilter.java | 98 ++++ .../internal/api/cloud/dto/IconOrder.java | 29 ++ .../internal/api/cloud/dto/IconType.java | 27 ++ .../internal/api/cloud/dto/Icons.java | 52 ++ .../internal/api/cloud/dto/IconsMetadata.java | 77 +++ .../internal/api/cloud/dto/Thumb.java | 77 +++ .../api/cloud/impl/LaMetricTimeCloudImpl.java | 41 +- .../api/common/impl/AbstractClient.java | 34 +- .../api/common/impl/GsonGenerator.java | 64 +++ .../ActionTypeAdapterFactory.java | 75 ++- .../ApplicationTypeAdapterFactory.java | 91 ++-- .../UpdateActionTypeAdapterFactory.java | 68 +++ .../CustomizedTypeAdapterFactory.java | 42 +- .../imported/DateTimeTypeAdapter.java | 43 ++ .../imported/DurationTypeAdapter.java | 34 ++ .../imported/InstantTypeAdapter.java | 34 ++ .../imported/JSR310TypeAdapters.java | 117 +++++ .../imported/LocalDateTimeTypeAdapter.java | 34 ++ .../imported/LocalDateTypeAdapter.java | 34 ++ .../imported/LocalTimeTypeAdapter.java | 34 ++ .../imported/MonthDayTypeAdapter.java | 34 ++ .../imported/OffsetDateTimeTypeAdapter.java | 34 ++ .../imported/OffsetTimeTypeAdapter.java | 34 ++ .../imported/PeriodTypeAdapter.java | 34 ++ .../imported/RuntimeTypeAdapterFactory.java | 455 ++++++++++++++++++ .../imported/TemporalTypeAdapter.java | 68 +++ .../imported/YearMonthTypeAdapter.java | 34 ++ .../imported/YearTypeAdapter.java | 34 ++ .../imported/ZonedDateTimeTypeAdapter.java | 34 ++ .../internal/api/dto/ApiValue.java | 30 ++ .../internal/api/dto/ClockApp.java | 69 +++ .../internal/api/dto/CoreAction.java | 38 ++ .../internal/api/dto/CoreApplication.java | 30 ++ .../internal/api/dto/CoreApps.java | 50 ++ .../internal/api/dto/CountdownApp.java | 62 +++ .../lametrictime/internal/api/dto/Icon.java | 22 + .../lametrictime/internal/api/dto}/Icons.java | 53 +- .../internal/api/dto/RadioApp.java | 49 ++ .../internal/api/dto/StopwatchApp.java | 44 ++ .../internal/api/dto/WeatherApp.java | 34 ++ .../api/dto/enums/BrightnessMode.java | 43 ++ .../internal/api/dto/enums/DisplayType.java | 45 ++ .../internal/api/dto/enums/IconType.java | 44 ++ .../internal/api/dto/enums/IpMode.java | 43 ++ .../internal/api/dto/enums/Priority.java | 44 ++ .../internal/api/dto}/enums/Sound.java | 57 +-- .../internal/api/dto/enums/SoundCategory.java | 43 ++ .../api/dto/enums/WifiEncryption.java | 45 ++ .../internal/api/impl/AbstractDataIcon.java | 71 +++ .../internal/api/impl/DataIcon.java | 38 ++ .../internal/api/impl/FileIcon.java | 57 +++ .../internal/api/impl/HTTPIcon.java | 48 ++ .../internal/api/impl/KeyIcon.java | 35 ++ .../internal/api/impl/LaMetricTimeImpl.java | 291 +++++++++++ .../api/local/ApplicationActionException.java | 51 ++ .../local/ApplicationActivationException.java | 51 ++ .../local/ApplicationNotFoundException.java | 51 ++ .../api/local/LaMetricTimeException.java | 69 +++ .../internal/api/local/LaMetricTimeLocal.java | 92 ++++ .../api/local/LocalConfiguration.java | 172 +++---- .../local/NotificationCreationException.java | 51 ++ .../local/NotificationNotFoundException.java | 51 ++ .../internal/api/local/UpdateException.java | 50 ++ .../internal/api/local/dto/Action.java | 103 ++++ .../internal/api/local/dto/Api.java | 60 +++ .../internal/api/local/dto}/Application.java | 121 ++--- .../internal/api/local/dto/Audio.java | 44 ++ .../api/local/dto/AudioUpdateResult.java | 52 ++ .../internal/api/local/dto}/Bluetooth.java | 84 ++-- .../api/local/dto/BluetoothUpdateResult.java | 52 ++ .../api/local/dto/BooleanParameter.java | 60 +++ .../internal/api/local/dto}/Device.java | 120 ++--- .../internal/api/local/dto/Display.java | 124 +++++ .../api/local/dto/DisplayUpdateResult.java | 52 ++ .../internal/api/local/dto}/Endpoints.java | 165 +++---- .../internal/api/local/dto/Error.java | 44 ++ .../internal/api/local/dto/Failure.java | 47 ++ .../internal/api/local/dto}/Frame.java | 75 ++- .../internal/api/local/dto/GoalData.java | 146 ++++++ .../api/local/dto/IntegerParameter.java | 60 +++ .../internal/api/local/dto/Modes.java | 60 +++ .../internal/api/local/dto}/Notification.java | 102 ++-- .../api/local/dto/NotificationModel.java | 78 +++ .../api/local/dto/NotificationResult.java | 52 ++ .../internal/api/local/dto/Parameter.java | 49 ++ .../internal/api/local/dto/Screensaver.java | 76 +++ .../internal/api/local/dto/Sound.java | 76 +++ .../api/local/dto/StringParameter.java | 76 +++ .../internal/api/local/dto/TimeBased.java | 44 ++ .../internal/api/local/dto/UpdateAction.java | 34 ++ .../internal/api/local/dto/WhenDark.java | 44 ++ .../internal/api/local/dto}/Widget.java | 123 ++--- .../internal/api/local/dto/WidgetUpdates.java | 46 ++ .../internal/api/local/dto}/Wifi.java | 111 ++--- .../api/local/impl/LaMetricTimeLocalImpl.java | 147 +++--- .../config/LaMetricTimeAppConfiguration.java | 9 + .../config/LaMetricTimeConfiguration.java | 7 + .../LaMetricTimeAppDiscoveryService.java | 8 +- .../LaMetricTimeDiscoveryParticipant.java | 7 +- .../AbstractLaMetricTimeAppHandler.java | 18 +- .../internal/handler/ClockAppHandler.java | 9 +- .../internal/handler/CountdownAppHandler.java | 9 +- .../handler/LaMetricTimeAppHandler.java | 7 +- .../internal/handler/LaMetricTimeHandler.java | 35 +- .../internal/handler/RadioAppHandler.java | 9 +- .../internal/handler/StopwatchAppHandler.java | 9 +- .../internal/handler/WeatherAppHandler.java | 9 +- .../api/AllIntegrationTestsSuite.java | 31 ++ .../internal/api/AllUnitTestsSuite.java | 31 ++ .../api/dto/enums/BrightnessModeTest.java | 41 ++ .../api/dto/enums/DisplayTypeTest.java | 41 ++ .../internal/api/dto/enums/IconTypeTest.java | 41 ++ .../internal/api/dto/enums/IpModeTest.java | 41 ++ .../internal/api/dto/enums/PriorityTest.java | 41 ++ .../api/dto/enums/SoundCategoryTest.java | 41 ++ .../internal/api/dto/enums/SoundTest.java | 41 ++ .../api/dto/enums/WifiEncryptionTest.java | 41 ++ .../internal/api/impl/FileIconTest.java | 59 +++ .../internal/api/local/dto}/ActionTest.java | 43 +- .../api/local/dto}/ApplicationTest.java | 66 ++- .../internal/api/local/dto/AudioTest.java | 52 ++ .../internal/api/local/dto/BluetoothTest.java | 71 +++ .../internal/api/local/dto}/FrameTest.java | 63 ++- .../internal/api/local/dto/GoalDataTest.java | 55 +++ .../api/local/dto}/UpdateActionTest.java | 28 +- .../internal/api/local/dto/WidgetTest.java | 67 +++ .../api/local/dto}/WidgetUpdatesTest.java | 30 +- .../local/impl/LaMetricTimeLocalImplIT.java | 71 +-- .../internal/api/test/AbstractTest.java | 40 ++ .../internal/api/test/TestUtil.java | 45 ++ .../{ => internal}/api/impl/README | 0 .../{ => internal}/api/impl/info.png | Bin .../{ => internal}/api/impl/smile.gif | Bin .../api/local/dto}/action.json | 0 .../api/local/dto}/application-all.json | 0 .../api/local/dto}/application-null-maps.json | 0 .../api/local/dto}/audio.json | 0 .../api/local/dto}/bluetooth-address.json | 0 .../api/local/dto}/bluetooth-mac-address.json | 0 .../api/local/dto}/bluetooth-mac.json | 0 .../api/local/dto}/frame-chart.json | 0 .../api/local/dto}/frame-goal.json | 0 .../api/local/dto}/frame-simple.json | 0 .../api/local/dto}/goal-data.json | 0 .../api/local/dto}/update-action.json | 0 .../api/local/dto}/widget-updates.json | 0 .../api/local/dto}/widget.json | 0 265 files changed, 6989 insertions(+), 7623 deletions(-) delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/Configuration.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/CloudConfiguration.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/LaMetricTimeCloud.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconField.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconFilter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconOrder.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconType.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icons.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconsMetadata.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Thumb.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/GsonGenerator.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DurationTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/InstantTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/AbstractDataIcon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/DataIcon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/FileIcon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/HTTPIcon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/KeyIcon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/LaMetricTimeImpl.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActionException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActivationException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationNotFoundException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeLocal.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationCreationException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationNotFoundException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/UpdateException.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Action.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Api.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Audio.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/AudioUpdateResult.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BluetoothUpdateResult.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BooleanParameter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Display.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/DisplayUpdateResult.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Error.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Failure.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/GoalData.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/IntegerParameter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Modes.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationModel.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationResult.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Parameter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Screensaver.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Sound.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/StringParameter.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/TimeBased.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/UpdateAction.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WhenDark.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WidgetUpdates.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ApiValue.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ClockApp.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreAction.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApplication.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApps.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CountdownApp.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icon.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/RadioApp.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/StopwatchApp.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/WeatherApp.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/BrightnessMode.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/DisplayType.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IconType.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IpMode.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Priority.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/SoundCategory.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/WifiEncryption.java rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/authentication/BasicAuthenticator.java (98%) rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/authentication/HttpAuthenticationFeature.java (99%) rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/authentication/HttpAuthenticationFilter.java (99%) rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/authentication/RequestAuthenticationException.java (97%) rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/authentication/ResponseAuthenticationException.java (97%) rename bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/{ => internal}/api/filter/LoggingFilter.java (99%) delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllIntegrationTestsSuite.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllUnitTestsSuite.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/impl/FileIconTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/AudioTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/BluetoothTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/GoalDataTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/BrightnessModeTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/DisplayTypeTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IconTypeTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IpModeTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/PriorityTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundCategoryTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/WifiEncryptionTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/AbstractTest.java delete mode 100644 bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/TestUtil.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/Configuration.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/LaMetricTime.java (80%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/CloudConfiguration.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/LaMetricTimeCloud.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconField.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconFilter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconOrder.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconType.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icons.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconsMetadata.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Thumb.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/cloud/impl/LaMetricTimeCloudImpl.java (59%) rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/common/impl/AbstractClient.java (59%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/GsonGenerator.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/common/impl/typeadapters/ActionTypeAdapterFactory.java (51%) rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java (57%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java (72%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DurationTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/InstantTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ApiValue.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ClockApp.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreAction.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApplication.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApps.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CountdownApp.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icon.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/model => main/java/org/openhab/binding/lametrictime/internal/api/dto}/Icons.java (61%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/RadioApp.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/StopwatchApp.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/WeatherApp.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessMode.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayType.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconType.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpMode.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Priority.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/model => main/java/org/openhab/binding/lametrictime/internal/api/dto}/enums/Sound.java (67%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategory.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryption.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/AbstractDataIcon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/DataIcon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/FileIcon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/HTTPIcon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/KeyIcon.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/LaMetricTimeImpl.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActionException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActivationException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationNotFoundException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeLocal.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/local/LocalConfiguration.java (54%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationCreationException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationNotFoundException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/UpdateException.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Action.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Api.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Application.java (52%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Audio.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioUpdateResult.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Bluetooth.java (55%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothUpdateResult.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BooleanParameter.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Device.java (53%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Display.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/DisplayUpdateResult.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Endpoints.java (63%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Error.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Failure.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Frame.java (50%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalData.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/IntegerParameter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Modes.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Notification.java (52%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationModel.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationResult.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Parameter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Screensaver.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Sound.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/StringParameter.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/TimeBased.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateAction.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WhenDark.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Widget.java (51%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdates.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime/api/local/model => main/java/org/openhab/binding/lametrictime/internal/api/local/dto}/Wifi.java (67%) rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/java/org/openhab/binding/lametrictime => main/java/org/openhab/binding/lametrictime/internal}/api/local/impl/LaMetricTimeLocalImpl.java (71%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllIntegrationTestsSuite.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllUnitTestsSuite.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessModeTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayTypeTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconTypeTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpModeTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/PriorityTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategoryTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryptionTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/impl/FileIconTest.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime/api/local/model => test/java/org/openhab/binding/lametrictime/internal/api/local/dto}/ActionTest.java (56%) rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime/api/local/model => test/java/org/openhab/binding/lametrictime/internal/api/local/dto}/ApplicationTest.java (63%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothTest.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime/api/local/model => test/java/org/openhab/binding/lametrictime/internal/api/local/dto}/FrameTest.java (54%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalDataTest.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime/api/local/model => test/java/org/openhab/binding/lametrictime/internal/api/local/dto}/UpdateActionTest.java (60%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetTest.java rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime/api/local/model => test/java/org/openhab/binding/lametrictime/internal/api/local/dto}/WidgetUpdatesTest.java (62%) rename bundles/org.openhab.binding.lametrictime/src/{3rdparty/test/org/openhab/binding/lametrictime => test/java/org/openhab/binding/lametrictime/internal}/api/local/impl/LaMetricTimeLocalImplIT.java (78%) create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/AbstractTest.java create mode 100644 bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/TestUtil.java rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{ => internal}/api/impl/README (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{ => internal}/api/impl/info.png (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{ => internal}/api/impl/smile.gif (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/action.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/application-all.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/application-null-maps.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/audio.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/bluetooth-address.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/bluetooth-mac-address.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/bluetooth-mac.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/frame-chart.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/frame-goal.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/frame-simple.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/goal-data.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/update-action.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/widget-updates.json (100%) rename bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/{api/local/model => internal/api/local/dto}/widget.json (100%) diff --git a/bundles/org.openhab.binding.lametrictime/NOTICE b/bundles/org.openhab.binding.lametrictime/NOTICE index f86250399..41865e02f 100644 --- a/bundles/org.openhab.binding.lametrictime/NOTICE +++ b/bundles/org.openhab.binding.lametrictime/NOTICE @@ -14,11 +14,6 @@ https://github.com/openhab/openhab-addons == Third-party Content -The sources of liblametrictime-java are included in src/3rdparty/java and have been slightly adapted. -* License: Apache 2.0 License -* Project: https://github.com/syphr42/liblametrictime-java - - -This binding includes a class from Jersey in the src/3rdparty/java folder. +This binding includes classes from Jersey in the src/3rdparty/java folder. * License: CDDL License * Project: https://eclipse-ee4j.github.io/jersey/ \ No newline at end of file diff --git a/bundles/org.openhab.binding.lametrictime/pom.xml b/bundles/org.openhab.binding.lametrictime/pom.xml index 47658a8b0..5a58a693c 100644 --- a/bundles/org.openhab.binding.lametrictime/pom.xml +++ b/bundles/org.openhab.binding.lametrictime/pom.xml @@ -35,18 +35,6 @@ - - add-test-source - generate-sources - - add-test-source - - - - src/3rdparty/test - - - diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/Configuration.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/Configuration.java deleted file mode 100644 index 08601d054..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/Configuration.java +++ /dev/null @@ -1,162 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api; - -import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration; -import org.openhab.binding.lametrictime.api.local.LocalConfiguration; - -public class Configuration -{ - private String deviceHost; - private String deviceApiKey; - - private boolean ignoreDeviceCertificateValidation = true; - private boolean ignoreDeviceHostnameValidation = true; - - private boolean logging = false; - private String logLevel = "INFO"; - private int logMax = 104857600; // 100kb - - public String getDeviceHost() - { - return deviceHost; - } - - public void setDeviceHost(String deviceHost) - { - this.deviceHost = deviceHost; - } - - public Configuration withDeviceHost(String deviceHost) - { - this.deviceHost = deviceHost; - return this; - } - - public String getDeviceApiKey() - { - return deviceApiKey; - } - - public void setDeviceApiKey(String deviceApiKey) - { - this.deviceApiKey = deviceApiKey; - } - - public Configuration withDeviceApiKey(String deviceApiKey) - { - this.deviceApiKey = deviceApiKey; - return this; - } - - public boolean isIgnoreDeviceCertificateValidation() - { - return ignoreDeviceCertificateValidation; - } - - public void setIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) - { - this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation; - } - - public Configuration withIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) - { - this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation; - return this; - } - - public boolean isIgnoreDeviceHostnameValidation() - { - return ignoreDeviceHostnameValidation; - } - - public void setIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) - { - this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation; - } - - public Configuration withIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) - { - this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation; - return this; - } - - public boolean isLogging() - { - return logging; - } - - public void setLogging(boolean logging) - { - this.logging = logging; - } - - public Configuration withLogging(boolean logging) - { - this.logging = logging; - return this; - } - - public String getLogLevel() - { - return logLevel; - } - - public void setLogLevel(String logLevel) - { - this.logLevel = logLevel; - } - - public Configuration withLogLevel(String logLevel) - { - this.logLevel = logLevel; - return this; - } - - public int getLogMax() - { - return logMax; - } - - public void setLogMax(int logMax) - { - this.logMax = logMax; - } - - public Configuration withLogMax(int logMax) - { - this.logMax = logMax; - return this; - } - - public LocalConfiguration getLocalConfig() - { - return new LocalConfiguration().withHost(deviceHost) - .withApiKey(deviceApiKey) - .withIgnoreCertificateValidation(ignoreDeviceCertificateValidation) - .withIgnoreHostnameValidation(ignoreDeviceHostnameValidation) - .withLogging(logging) - .withLogLevel(logLevel) - .withLogMax(logMax); - } - - public CloudConfiguration getCloudConfig() - { - return new CloudConfiguration().withLogging(logging) - .withLogLevel(logLevel) - .withLogMax(logMax); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/CloudConfiguration.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/CloudConfiguration.java deleted file mode 100644 index 8f217a0e6..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/CloudConfiguration.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud; - -import java.net.URI; - -public class CloudConfiguration -{ - private URI baseUri = URI.create("https://developer.lametric.com/api/v2"); - - private boolean logging = false; - private String logLevel = "INFO"; - private int logMax = 104857600; // 100kb - - public URI getBaseUri() - { - return baseUri; - } - - public void setBaseUri(URI baseUri) - { - this.baseUri = baseUri; - } - - public CloudConfiguration withBaseUri(URI baseUri) - { - this.baseUri = baseUri; - return this; - } - - public boolean isLogging() - { - return logging; - } - - public void setLogging(boolean logging) - { - this.logging = logging; - } - - public CloudConfiguration withLogging(boolean logging) - { - this.logging = logging; - return this; - } - - public String getLogLevel() - { - return logLevel; - } - - public void setLogLevel(String logLevel) - { - this.logLevel = logLevel; - } - - public CloudConfiguration withLogLevel(String logLevel) - { - this.logLevel = logLevel; - return this; - } - - public int getLogMax() - { - return logMax; - } - - public void setLogMax(int logMax) - { - this.logMax = logMax; - } - - public CloudConfiguration withLogMax(int logMax) - { - this.logMax = logMax; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/LaMetricTimeCloud.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/LaMetricTimeCloud.java deleted file mode 100644 index 06f06ad0a..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/LaMetricTimeCloud.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud; - -import javax.ws.rs.client.ClientBuilder; - -import org.openhab.binding.lametrictime.api.cloud.impl.LaMetricTimeCloudImpl; -import org.openhab.binding.lametrictime.api.cloud.model.IconFilter; -import org.openhab.binding.lametrictime.api.cloud.model.Icons; - -public interface LaMetricTimeCloud -{ - public Icons getIcons(); - - public Icons getIcons(IconFilter filter); - - public static LaMetricTimeCloud create(CloudConfiguration config) - { - return new LaMetricTimeCloudImpl(config); - } - - public static LaMetricTimeCloud create(CloudConfiguration config, ClientBuilder clientBuilder) - { - return new LaMetricTimeCloudImpl(config, clientBuilder); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icon.java deleted file mode 100644 index 99df9454f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icon.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -public class Icon -{ - private Integer id; - private String title; - private String code; - private IconType type; - private String category; - private String url; - private Thumb thumb; - - public Integer getId() - { - return id; - } - - public void setId(Integer id) - { - this.id = id; - } - - public Icon withId(Integer id) - { - this.id = id; - return this; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Icon withTitle(String title) - { - this.title = title; - return this; - } - - public String getCode() - { - return code; - } - - public void setCode(String code) - { - this.code = code; - } - - public Icon withCode(String code) - { - this.code = code; - return this; - } - - public IconType getType() - { - return type; - } - - public void setType(IconType type) - { - this.type = type; - } - - public Icon withType(IconType type) - { - this.type = type; - return this; - } - - public String getCategory() - { - return category; - } - - public void setCategory(String category) - { - this.category = category; - } - - public Icon withCategory(String category) - { - this.category = category; - return this; - } - - public String getUrl() - { - return url; - } - - public void setUrl(String url) - { - this.url = url; - } - - public Icon withUrl(String url) - { - this.url = url; - return this; - } - - public Thumb getThumb() - { - return thumb; - } - - public void setThumb(Thumb thumb) - { - this.thumb = thumb; - } - - public Icon withThumb(Thumb thumb) - { - this.thumb = thumb; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconField.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconField.java deleted file mode 100644 index 4ea57dc07..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconField.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -import com.google.gson.annotations.SerializedName; - -public enum IconField -{ - @SerializedName("id") - ID, - @SerializedName("title") - TITLE, - @SerializedName("code") - CODE, - @SerializedName("type") - TYPE, - @SerializedName("url") - URL, - @SerializedName("thumb") - THUMB -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconFilter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconFilter.java deleted file mode 100644 index 2d2da0a45..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconFilter.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -import java.util.List; - -public class IconFilter -{ - private Integer page; - private Integer pageSize; - private List fields; - private IconOrder order; - - public Integer getPage() - { - return page; - } - - public void setPage(Integer page) - { - this.page = page; - } - - public IconFilter withPage(Integer page) - { - this.page = page; - return this; - } - - public Integer getPageSize() - { - return pageSize; - } - - public void setPageSize(Integer pageSize) - { - this.pageSize = pageSize; - } - - public IconFilter withPageSize(Integer pageSize) - { - this.pageSize = pageSize; - return this; - } - - public List getFields() - { - return fields; - } - - public String getFieldsString() - { - if (fields == null || fields.isEmpty()) - { - return null; - } - - StringBuilder builder = new StringBuilder(); - builder.append(fields.get(0).name().toLowerCase()); - - for (int i = 1; i < fields.size(); i++) - { - builder.append(',').append(fields.get(i).name().toLowerCase()); - } - - return builder.toString(); - } - - public void setFields(List fields) - { - this.fields = fields; - } - - public IconFilter withFields(List fields) - { - this.fields = fields; - return this; - } - - public IconOrder getOrder() - { - return order; - } - - public String getOrderString() - { - return order == null ? null : order.name().toLowerCase(); - } - - public void setOrder(IconOrder order) - { - this.order = order; - } - - public IconFilter withOrder(IconOrder order) - { - this.order = order; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconOrder.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconOrder.java deleted file mode 100644 index bad2ad35d..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconOrder.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -import com.google.gson.annotations.SerializedName; - -public enum IconOrder -{ - @SerializedName("popular") - POPULAR, - @SerializedName("newest") - NEWEST, - @SerializedName("title") - TITLE -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconType.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconType.java deleted file mode 100644 index 8c7290f9c..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconType.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -import com.google.gson.annotations.SerializedName; - -public enum IconType -{ - @SerializedName("picture") - PICTURE, - @SerializedName("movie") - MOVIE -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icons.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icons.java deleted file mode 100644 index e38a5f62b..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Icons.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -import java.util.ArrayList; -import java.util.List; - -public class Icons -{ - private IconsMetadata meta; - private List data = new ArrayList(); - - public IconsMetadata getMeta() - { - return meta; - } - - public void setMeta(IconsMetadata meta) - { - this.meta = meta; - } - - public Icons withMeta(IconsMetadata meta) - { - this.meta = meta; - return this; - } - - public List getData() - { - return data; - } - - public void setData(List data) - { - this.data = data; - } - - public Icons withData(List data) - { - this.data = data; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconsMetadata.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconsMetadata.java deleted file mode 100644 index 2a7f6395f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/IconsMetadata.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -public class IconsMetadata -{ - private Integer totalIconCount; - private Integer page; - private Integer pageSize; - private Integer pageCount; - - public Integer getTotalIconCount() - { - return totalIconCount; - } - - public void setTotalIconCount(Integer totalIconCount) - { - this.totalIconCount = totalIconCount; - } - - public IconsMetadata withTotalIconCount(Integer totalIconCount) - { - this.totalIconCount = totalIconCount; - return this; - } - - public Integer getPage() - { - return page; - } - - public void setPage(Integer page) - { - this.page = page; - } - - public IconsMetadata withPage(Integer page) - { - this.page = page; - return this; - } - - public Integer getPageSize() - { - return pageSize; - } - - public void setPageSize(Integer pageSize) - { - this.pageSize = pageSize; - } - - public IconsMetadata withPageSize(Integer pageSize) - { - this.pageSize = pageSize; - return this; - } - - public Integer getPageCount() - { - return pageCount; - } - - public void setPageCount(Integer pageCount) - { - this.pageCount = pageCount; - } - - public IconsMetadata withPageCount(Integer pageCount) - { - this.pageCount = pageCount; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Thumb.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Thumb.java deleted file mode 100644 index 6a25dc9da..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/model/Thumb.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.cloud.model; - -public class Thumb -{ - private String original; - private String small; - private String large; - private String xlarge; - - public String getOriginal() - { - return original; - } - - public void setOriginal(String original) - { - this.original = original; - } - - public Thumb withOriginal(String original) - { - this.original = original; - return this; - } - - public String getSmall() - { - return small; - } - - public void setSmall(String small) - { - this.small = small; - } - - public Thumb withSmall(String small) - { - this.small = small; - return this; - } - - public String getLarge() - { - return large; - } - - public void setLarge(String large) - { - this.large = large; - } - - public Thumb withLarge(String large) - { - this.large = large; - return this; - } - - public String getXlarge() - { - return xlarge; - } - - public void setXlarge(String xlarge) - { - this.xlarge = xlarge; - } - - public Thumb withXlarge(String xlarge) - { - this.xlarge = xlarge; - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/GsonGenerator.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/GsonGenerator.java deleted file mode 100644 index b363ab82f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/GsonGenerator.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.common.impl; - -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.ActionTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.ApplicationTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.UpdateActionTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.JSR310TypeAdapters; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.RuntimeTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.local.model.BooleanParameter; -import org.openhab.binding.lametrictime.api.local.model.IntegerParameter; -import org.openhab.binding.lametrictime.api.local.model.Parameter; -import org.openhab.binding.lametrictime.api.local.model.StringParameter; - -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -public class GsonGenerator -{ - public static Gson create() - { - return create(false); - } - - public static Gson create(boolean prettyPrint) - { - GsonBuilder builder = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) - .registerTypeAdapterFactory(new ApplicationTypeAdapterFactory()) - .registerTypeAdapterFactory(new ActionTypeAdapterFactory()) - .registerTypeAdapterFactory(new UpdateActionTypeAdapterFactory()) - .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(Parameter.class, - "data_type") - .registerSubtype(BooleanParameter.class, - "bool") - .registerSubtype(StringParameter.class, - "string") - .registerSubtype(IntegerParameter.class, - "int")); - - // add Java 8 Time API support - JSR310TypeAdapters.registerJSR310TypeAdapters(builder); - - if (prettyPrint) - { - builder.setPrettyPrinting(); - } - - return builder.create(); - } - - // @formatter:off - private GsonGenerator() {} - // @formatter:on -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java deleted file mode 100644 index a7ab0a363..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters; - -import java.util.Map.Entry; - -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; - -public class UpdateActionTypeAdapterFactory extends CustomizedTypeAdapterFactory -{ - private static final String PROPERTY_PARAMETERS = "params"; - private static final String PROPERTY_VALUE = "value"; - - public UpdateActionTypeAdapterFactory() - { - super(UpdateAction.class); - } - - @Override - protected void beforeWrite(UpdateAction source, JsonElement toSerialize) - { - if (toSerialize == null || toSerialize.isJsonNull()) - { - return; - } - - JsonObject actionObj = toSerialize.getAsJsonObject(); - if (actionObj == null || actionObj.isJsonNull()) - { - return; - } - - // rewrite parameters map from {name => Parameter} to {name => value} - JsonElement paramsElem = actionObj.get(PROPERTY_PARAMETERS); - if (paramsElem != null && !paramsElem.isJsonNull()) - { - JsonObject paramsObj = paramsElem.getAsJsonObject(); - actionObj.remove(PROPERTY_PARAMETERS); - - JsonObject newParamsObj = new JsonObject(); - for (Entry entry : paramsObj.entrySet()) - { - newParamsObj.add(entry.getKey(), - entry.getValue() - .getAsJsonObject() - .getAsJsonPrimitive(PROPERTY_VALUE)); - } - actionObj.add(PROPERTY_PARAMETERS, newParamsObj); - } - } - - @Override - protected void afterRead(JsonElement deserialized) - { - throw new UnsupportedOperationException(UpdateAction.class.getName() - + " cannot be derialized"); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java deleted file mode 100644 index 16a4d144f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.util.function.Function; - -/** - * Abstract type adapter for jsr310 date-time types. - * - * @author Christophe Bornet - */ -abstract class DateTimeTypeAdapter extends TemporalTypeAdapter { - - DateTimeTypeAdapter(Function parseFunction) { - super(parseFunction); - } - - @Override - public String preProcess(String in) { - if (in.endsWith("+0000")) { - return in.substring(0, in.length()-5) + "Z"; - } - return in; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DurationTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DurationTypeAdapter.java deleted file mode 100644 index bb5e7d010..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/DurationTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.Duration; - -/** - * Type adapter for jsr310 {@link Duration} class. - * - * @author Christophe Bornet - */ -public class DurationTypeAdapter extends TemporalTypeAdapter { - - public DurationTypeAdapter() { - super(Duration::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/InstantTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/InstantTypeAdapter.java deleted file mode 100644 index 6155e4fac..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/InstantTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.Instant; - -/** - * Type adapter for jsr310 {@link Instant} class. - * - * @author Christophe Bornet - */ -public class InstantTypeAdapter extends DateTimeTypeAdapter { - - public InstantTypeAdapter() { - super(Instant::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java deleted file mode 100644 index de58493bc..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import com.google.gson.GsonBuilder; - -import java.time.*; - -/** - * Helper methods to register JSR310 type adapters. - * - * @author Christophe Bornet - */ -public class JSR310TypeAdapters { - - private JSR310TypeAdapters() { - } - - public static GsonBuilder registerDurationTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(Duration.class, new DurationTypeAdapter()); - } - - public static GsonBuilder registerInstantTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(Instant.class, new InstantTypeAdapter()); - } - - public static GsonBuilder registerLocalDateTimeTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter()); - } - - public static GsonBuilder registerLocalDateTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter()); - } - - public static GsonBuilder registerLocalTimeTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(LocalTime.class, new LocalTimeTypeAdapter()); - } - - public static GsonBuilder registerMonthDayTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(MonthDay.class, new MonthDayTypeAdapter()); - } - - public static GsonBuilder registerOffsetDateTimeTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeTypeAdapter()); - } - - public static GsonBuilder registerOffsetTimeTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(OffsetTime.class, new OffsetTimeTypeAdapter()); - } - - public static GsonBuilder registerPeriodTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(Period.class, new PeriodTypeAdapter()); - } - - public static GsonBuilder registerYearMonthTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(YearMonth.class, new YearMonthTypeAdapter()); - } - - public static GsonBuilder registerYearTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(Year.class, new YearTypeAdapter()); - } - - public static GsonBuilder registerZonedDateTimeTypeAdapter(GsonBuilder gsonBuilder) { - return gsonBuilder.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeTypeAdapter()); - } - - - /** - * Helper method to register all the available JSR310 adapters at once. - * @param gsonBuilder the gsonBuilder on which all the JSR310 adapters must be registered. - * @return the gsonBuilder with the JSR310 adapters registered. - */ - public static GsonBuilder registerJSR310TypeAdapters(GsonBuilder gsonBuilder) { - registerDurationTypeAdapter(gsonBuilder); - registerInstantTypeAdapter(gsonBuilder); - registerLocalDateTimeTypeAdapter(gsonBuilder); - registerLocalDateTypeAdapter(gsonBuilder); - registerLocalTimeTypeAdapter(gsonBuilder); - registerMonthDayTypeAdapter(gsonBuilder); - registerOffsetDateTimeTypeAdapter(gsonBuilder); - registerOffsetTimeTypeAdapter(gsonBuilder); - registerPeriodTypeAdapter(gsonBuilder); - registerYearMonthTypeAdapter(gsonBuilder); - registerYearTypeAdapter(gsonBuilder); - registerZonedDateTimeTypeAdapter(gsonBuilder); - - return gsonBuilder; - } - - -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java deleted file mode 100644 index 2a97d1a51..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.LocalDateTime; - -/** - * Type adapter for jsr310 {@link LocalDateTime} class. - * - * @author Christophe Bornet - */ -public class LocalDateTimeTypeAdapter extends DateTimeTypeAdapter { - - public LocalDateTimeTypeAdapter() { - super(LocalDateTime::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java deleted file mode 100644 index 34c9978d0..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.LocalDate; - -/** - * Type adapter for jsr310 {@link LocalDate} class. - * - * @author Christophe Bornet - */ -public class LocalDateTypeAdapter extends TemporalTypeAdapter { - - public LocalDateTypeAdapter() { - super(LocalDate::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java deleted file mode 100644 index e2b8052c3..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.LocalTime; - -/** - * Type adapter for jsr310 {@link LocalTime} class. - * - * @author Christophe Bornet - */ -public class LocalTimeTypeAdapter extends TemporalTypeAdapter { - - public LocalTimeTypeAdapter() { - super(LocalTime::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java deleted file mode 100644 index e942a9b3e..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.MonthDay; - -/** - * Type adapter for jsr310 {@link MonthDay} class. - * - * @author Christophe Bornet - */ -public class MonthDayTypeAdapter extends TemporalTypeAdapter { - - public MonthDayTypeAdapter() { - super(MonthDay::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java deleted file mode 100644 index fab6a92bf..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.OffsetDateTime; - -/** - * Type adapter for jsr310 {@link OffsetDateTime} class. - * - * @author Christophe Bornet - */ -public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter { - - public OffsetDateTimeTypeAdapter() { - super(OffsetDateTime::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java deleted file mode 100644 index 1035cc4f9..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.OffsetTime; - -/** - * Type adapter for jsr310 {@link OffsetTime} class. - * - * @author Christophe Bornet - */ -public class OffsetTimeTypeAdapter extends TemporalTypeAdapter { - - public OffsetTimeTypeAdapter() { - super(OffsetTime::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java deleted file mode 100644 index e1a38fb45..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.Period; - -/** - * Type adapter for jsr310 {@link Period} class. - * - * @author Christophe Bornet - */ -public class PeriodTypeAdapter extends TemporalTypeAdapter { - - public PeriodTypeAdapter() { - super(Period::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java deleted file mode 100644 index ae1cb753e..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright (C) 2011 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Copied from - * https://raw.githubusercontent.com/google/gson/master/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java - * and repackaged here with additional content from - * com.google.gson.internal.{Streams,TypeAdapters,LazilyParsedNumber} - * to avoid using the internal package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.io.EOFException; -import java.io.IOException; -import java.io.ObjectStreamException; -import java.math.BigDecimal; -import java.util.LinkedHashMap; -import java.util.Map; - -import com.google.gson.Gson; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonIOException; -import com.google.gson.JsonNull; -import com.google.gson.JsonObject; -import com.google.gson.JsonParseException; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSyntaxException; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.google.gson.stream.MalformedJsonException; - -/** - * Adapts values whose runtime type may differ from their declaration type. This - * is necessary when a field's type is not the same type that GSON should create - * when deserializing that field. For example, consider these types: - *
   {@code
- *   abstract class Shape {
- *     int x;
- *     int y;
- *   }
- *   class Circle extends Shape {
- *     int radius;
- *   }
- *   class Rectangle extends Shape {
- *     int width;
- *     int height;
- *   }
- *   class Diamond extends Shape {
- *     int width;
- *     int height;
- *   }
- *   class Drawing {
- *     Shape bottomShape;
- *     Shape topShape;
- *   }
- * }
- *

Without additional type information, the serialized JSON is ambiguous. Is - * the bottom shape in this drawing a rectangle or a diamond?

   {@code
- *   {
- *     "bottomShape": {
- *       "width": 10,
- *       "height": 5,
- *       "x": 0,
- *       "y": 0
- *     },
- *     "topShape": {
- *       "radius": 2,
- *       "x": 4,
- *       "y": 1
- *     }
- *   }}
- * This class addresses this problem by adding type information to the - * serialized JSON and honoring that type information when the JSON is - * deserialized:
   {@code
- *   {
- *     "bottomShape": {
- *       "type": "Diamond",
- *       "width": 10,
- *       "height": 5,
- *       "x": 0,
- *       "y": 0
- *     },
- *     "topShape": {
- *       "type": "Circle",
- *       "radius": 2,
- *       "x": 4,
- *       "y": 1
- *     }
- *   }}
- * Both the type field name ({@code "type"}) and the type labels ({@code - * "Rectangle"}) are configurable. - * - *

Registering Types

- * Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field - * name to the {@link #of} factory method. If you don't supply an explicit type - * field name, {@code "type"} will be used.
   {@code
- *   RuntimeTypeAdapterFactory shapeAdapterFactory
- *       = RuntimeTypeAdapterFactory.of(Shape.class, "type");
- * }
- * Next register all of your subtypes. Every subtype must be explicitly - * registered. This protects your application from injection attacks. If you - * don't supply an explicit type label, the type's simple name will be used. - *
   {@code
- *   shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
- *   shapeAdapter.registerSubtype(Circle.class, "Circle");
- *   shapeAdapter.registerSubtype(Diamond.class, "Diamond");
- * }
- * Finally, register the type adapter factory in your application's GSON builder: - *
   {@code
- *   Gson gson = new GsonBuilder()
- *       .registerTypeAdapterFactory(shapeAdapterFactory)
- *       .create();
- * }
- * Like {@code GsonBuilder}, this API supports chaining:
   {@code
- *   RuntimeTypeAdapterFactory shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class)
- *       .registerSubtype(Rectangle.class)
- *       .registerSubtype(Circle.class)
- *       .registerSubtype(Diamond.class);
- * }
- */ -public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory { - private final Class baseType; - private final String typeFieldName; - private final Map> labelToSubtype = new LinkedHashMap>(); - private final Map, String> subtypeToLabel = new LinkedHashMap, String>(); - - private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName) { - if (typeFieldName == null || baseType == null) { - throw new NullPointerException(); - } - this.baseType = baseType; - this.typeFieldName = typeFieldName; - } - - /** - * Creates a new runtime type adapter using for {@code baseType} using {@code - * typeFieldName} as the type field name. Type field names are case sensitive. - */ - public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { - return new RuntimeTypeAdapterFactory(baseType, typeFieldName); - } - - /** - * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as - * the type field name. - */ - public static RuntimeTypeAdapterFactory of(Class baseType) { - return new RuntimeTypeAdapterFactory(baseType, "type"); - } - - /** - * Registers {@code type} identified by {@code label}. Labels are case - * sensitive. - * - * @throws IllegalArgumentException if either {@code type} or {@code label} - * have already been registered on this type adapter. - */ - public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) { - if (type == null || label == null) { - throw new NullPointerException(); - } - if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) { - throw new IllegalArgumentException("types and labels must be unique"); - } - labelToSubtype.put(label, type); - subtypeToLabel.put(type, label); - return this; - } - - /** - * Registers {@code type} identified by its {@link Class#getSimpleName simple - * name}. Labels are case sensitive. - * - * @throws IllegalArgumentException if either {@code type} or its simple name - * have already been registered on this type adapter. - */ - public RuntimeTypeAdapterFactory registerSubtype(Class type) { - return registerSubtype(type, type.getSimpleName()); - } - - public TypeAdapter create(Gson gson, TypeToken type) { - if (type.getRawType() != baseType) { - return null; - } - - final Map> labelToDelegate - = new LinkedHashMap>(); - final Map, TypeAdapter> subtypeToDelegate - = new LinkedHashMap, TypeAdapter>(); - for (Map.Entry> entry : labelToSubtype.entrySet()) { - TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue())); - labelToDelegate.put(entry.getKey(), delegate); - subtypeToDelegate.put(entry.getValue(), delegate); - } - - return new TypeAdapter() { - @Override public R read(JsonReader in) throws IOException { - JsonElement jsonElement = RuntimeTypeAdapterFactory.parse(in); - JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); - if (labelJsonElement == null) { - throw new JsonParseException("cannot deserialize " + baseType - + " because it does not define a field named " + typeFieldName); - } - String label = labelJsonElement.getAsString(); - @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label); - if (delegate == null) { - throw new JsonParseException("cannot deserialize " + baseType + " subtype named " - + label + "; did you forget to register a subtype?"); - } - return delegate.fromJsonTree(jsonElement); - } - - @Override public void write(JsonWriter out, R value) throws IOException { - Class srcType = value.getClass(); - String label = subtypeToLabel.get(srcType); - @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType); - if (delegate == null) { - throw new JsonParseException("cannot serialize " + srcType.getName() - + "; did you forget to register a subtype?"); - } - JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); - if (jsonObject.has(typeFieldName)) { - throw new JsonParseException("cannot serialize " + srcType.getName() - + " because it already defines a field named " + typeFieldName); - } - JsonObject clone = new JsonObject(); - clone.add(typeFieldName, new JsonPrimitive(label)); - for (Map.Entry e : jsonObject.entrySet()) { - clone.add(e.getKey(), e.getValue()); - } - RuntimeTypeAdapterFactory.write(clone, out); - } - }.nullSafe(); - } - - /** - * Takes a reader in any state and returns the next value as a JsonElement. - */ - private static JsonElement parse(JsonReader reader) throws JsonParseException { - boolean isEmpty = true; - try { - reader.peek(); - isEmpty = false; - return RuntimeTypeAdapterFactory.JSON_ELEMENT.read(reader); - } catch (EOFException e) { - /* - * For compatibility with JSON 1.5 and earlier, we return a JsonNull for - * empty documents instead of throwing. - */ - if (isEmpty) { - return JsonNull.INSTANCE; - } - // The stream ended prematurely so it is likely a syntax error. - throw new JsonSyntaxException(e); - } catch (MalformedJsonException e) { - throw new JsonSyntaxException(e); - } catch (IOException e) { - throw new JsonIOException(e); - } catch (NumberFormatException e) { - throw new JsonSyntaxException(e); - } - } - - /** - * Writes the JSON element to the writer, recursively. - */ - private static void write(JsonElement element, JsonWriter writer) throws IOException { - RuntimeTypeAdapterFactory.JSON_ELEMENT.write(writer, element); - } - - private static final TypeAdapter JSON_ELEMENT = new TypeAdapter() { - @Override public JsonElement read(JsonReader in) throws IOException { - switch (in.peek()) { - case STRING: - return new JsonPrimitive(in.nextString()); - case NUMBER: - String number = in.nextString(); - return new JsonPrimitive(new LazilyParsedNumber(number)); - case BOOLEAN: - return new JsonPrimitive(in.nextBoolean()); - case NULL: - in.nextNull(); - return JsonNull.INSTANCE; - case BEGIN_ARRAY: - JsonArray array = new JsonArray(); - in.beginArray(); - while (in.hasNext()) { - array.add(read(in)); - } - in.endArray(); - return array; - case BEGIN_OBJECT: - JsonObject object = new JsonObject(); - in.beginObject(); - while (in.hasNext()) { - object.add(in.nextName(), read(in)); - } - in.endObject(); - return object; - case END_DOCUMENT: - case NAME: - case END_OBJECT: - case END_ARRAY: - default: - throw new IllegalArgumentException(); - } - } - - @Override public void write(JsonWriter out, JsonElement value) throws IOException { - if (value == null || value.isJsonNull()) { - out.nullValue(); - } else if (value.isJsonPrimitive()) { - JsonPrimitive primitive = value.getAsJsonPrimitive(); - if (primitive.isNumber()) { - out.value(primitive.getAsNumber()); - } else if (primitive.isBoolean()) { - out.value(primitive.getAsBoolean()); - } else { - out.value(primitive.getAsString()); - } - - } else if (value.isJsonArray()) { - out.beginArray(); - for (JsonElement e : value.getAsJsonArray()) { - write(out, e); - } - out.endArray(); - - } else if (value.isJsonObject()) { - out.beginObject(); - for (Map.Entry e : value.getAsJsonObject().entrySet()) { - out.name(e.getKey()); - write(out, e.getValue()); - } - out.endObject(); - - } else { - throw new IllegalArgumentException("Couldn't write " + value.getClass()); - } - } - }; - - /** - * This class holds a number value that is lazily converted to a specific number type - * - * @author Inderjeet Singh - */ - public static final class LazilyParsedNumber extends Number { - private final String value; - - public LazilyParsedNumber(String value) { - this.value = value; - } - - @Override - public int intValue() { - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - try { - return (int) Long.parseLong(value); - } catch (NumberFormatException nfe) { - return new BigDecimal(value).intValue(); - } - } - } - - @Override - public long longValue() { - try { - return Long.parseLong(value); - } catch (NumberFormatException e) { - return new BigDecimal(value).longValue(); - } - } - - @Override - public float floatValue() { - return Float.parseFloat(value); - } - - @Override - public double doubleValue() { - return Double.parseDouble(value); - } - - @Override - public String toString() { - return value; - } - - /** - * If somebody is unlucky enough to have to serialize one of these, serialize - * it as a BigDecimal so that they won't need Gson on the other side to - * deserialize it. - */ - private Object writeReplace() throws ObjectStreamException { - return new BigDecimal(value); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java deleted file mode 100644 index 81dcddc40..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonToken; -import com.google.gson.stream.JsonWriter; - -import java.io.IOException; -import java.time.temporal.TemporalAccessor; -import java.util.Objects; -import java.util.function.Function; - -/** - * Abstract type adapter for jsr310 date-time types. - * - * @author Christophe Bornet - */ -abstract class TemporalTypeAdapter extends TypeAdapter { - - Function parseFunction; - - TemporalTypeAdapter(Function parseFunction) { - Objects.requireNonNull(parseFunction); - this.parseFunction = parseFunction; - } - - @Override - public void write(JsonWriter out, T value) throws IOException { - if (value == null) { - out.nullValue(); - } else { - out.value(value.toString()); - } - } - - @Override - public T read(JsonReader in) throws IOException { - if (in.peek() == JsonToken.NULL) { - in.nextNull(); - return null; - } - String temporalString = preProcess(in.nextString()); - return parseFunction.apply(temporalString); - } - - public String preProcess(String in) { - return in; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java deleted file mode 100644 index f491e5ae2..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.YearMonth; - -/** - * Type adapter for jsr310 {@link YearMonth} class. - * - * @author Christophe Bornet - */ -public class YearMonthTypeAdapter extends TemporalTypeAdapter { - - public YearMonthTypeAdapter() { - super(YearMonth::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearTypeAdapter.java deleted file mode 100644 index db406821b..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/YearTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.Year; - -/** - * Type adapter for jsr310 {@link Year} class. - * - * @author Christophe Bornet - */ -public class YearTypeAdapter extends TemporalTypeAdapter { - - public YearTypeAdapter() { - super(Year::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java deleted file mode 100644 index df751bd29..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2016 Gson Type Adapter Authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src - * and repackaged to avoid the default package. - */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; - -import java.time.ZonedDateTime; - -/** - * Type adapter for jsr310 {@link ZonedDateTime} class. - * - * @author Christophe Bornet - */ -public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter { - - public ZonedDateTimeTypeAdapter() { - super(ZonedDateTime::parse); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/AbstractDataIcon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/AbstractDataIcon.java deleted file mode 100644 index 6658b53e7..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/AbstractDataIcon.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import java.util.Base64; - -import org.openhab.binding.lametrictime.api.model.Icon; - -public abstract class AbstractDataIcon implements Icon -{ - private volatile Object CONFIGURE_FLAG; - - private String type; - private byte[] data; - - protected void configure() - { - if (CONFIGURE_FLAG == null) - { - synchronized (this) - { - if (CONFIGURE_FLAG == null) - { - populateFields(); - } - } - } - } - - protected String getType() - { - configure(); - return type; - } - - protected void setType(String type) - { - this.type = type; - } - - protected byte[] getData() - { - configure(); - return data; - } - - protected void setData(byte[] data) - { - this.data = data; - } - - @Override - public String toRaw() - { - return new StringBuilder().append("data:") - .append(getType()) - .append(";base64,") - .append(Base64.getEncoder().encodeToString(getData())) - .toString(); - } - - protected abstract void populateFields(); -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/DataIcon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/DataIcon.java deleted file mode 100644 index cbb15daa3..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/DataIcon.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -public class DataIcon extends AbstractDataIcon -{ - public DataIcon(String mimeType, byte[] data) - { - setType(mimeType); - setData(data); - } - - @Override - protected void configure() - { - // noop - } - - @Override - protected void populateFields() - { - // noop - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/FileIcon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/FileIcon.java deleted file mode 100644 index 1b40eeafa..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/FileIcon.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -import javax.activation.MimetypesFileTypeMap; - -public class FileIcon extends AbstractDataIcon -{ - private final MimetypesFileTypeMap mimeTypeMap = new MimetypesFileTypeMap(); - - private final Path path; - - public FileIcon(File file) - { - this(file.toPath()); - } - - public FileIcon(Path path) - { - this.path = path; - mimeTypeMap.addMimeTypes("image/png png PNG"); - } - - @Override - protected void populateFields() - { - setType(mimeTypeMap.getContentType(path.toFile())); - try - { - setData(Files.readAllBytes(path)); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/HTTPIcon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/HTTPIcon.java deleted file mode 100644 index 5a89c4be6..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/HTTPIcon.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import java.net.URI; - -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.core.Response; - -public class HTTPIcon extends AbstractDataIcon -{ - private final URI uri; - - public HTTPIcon(String uri) - { - this(URI.create(uri)); - } - - public HTTPIcon(URI uri) - { - this.uri = uri; - } - - @Override - protected void populateFields() - { - Client client = ClientBuilder.newBuilder().build(); - Response response = client.target(uri).request().get(); - - setType(response.getMediaType().toString()); - setData(response.readEntity(byte[].class)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/KeyIcon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/KeyIcon.java deleted file mode 100644 index b711cac1a..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/KeyIcon.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import org.openhab.binding.lametrictime.api.model.Icon; - -public class KeyIcon implements Icon -{ - private final String key; - - public KeyIcon(String key) - { - this.key = key; - } - - @Override - public String toRaw() - { - return key; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/LaMetricTimeImpl.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/LaMetricTimeImpl.java deleted file mode 100644 index cdf7f5ce7..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/impl/LaMetricTimeImpl.java +++ /dev/null @@ -1,334 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import static org.openhab.binding.lametrictime.api.model.ApiValue.raw; - -import java.util.Arrays; - -import javax.ws.rs.client.ClientBuilder; - -import org.openhab.binding.lametrictime.api.Configuration; -import org.openhab.binding.lametrictime.api.LaMetricTime; -import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration; -import org.openhab.binding.lametrictime.api.cloud.LaMetricTimeCloud; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; -import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException; -import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal; -import org.openhab.binding.lametrictime.api.local.LocalConfiguration; -import org.openhab.binding.lametrictime.api.local.NotificationCreationException; -import org.openhab.binding.lametrictime.api.local.UpdateException; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.Frame; -import org.openhab.binding.lametrictime.api.local.model.Notification; -import org.openhab.binding.lametrictime.api.local.model.NotificationModel; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; -import org.openhab.binding.lametrictime.api.local.model.Widget; -import org.openhab.binding.lametrictime.api.model.CoreAction; -import org.openhab.binding.lametrictime.api.model.CoreApplication; -import org.openhab.binding.lametrictime.api.model.CoreApps; -import org.openhab.binding.lametrictime.api.model.Icon; -import org.openhab.binding.lametrictime.api.model.Icons; -import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode; -import org.openhab.binding.lametrictime.api.model.enums.Priority; -import org.openhab.binding.lametrictime.api.model.enums.Sound; - -public class LaMetricTimeImpl implements LaMetricTime -{ - private final LaMetricTimeLocal local; - private final LaMetricTimeCloud cloud; - - private final Object muteLock = new Object(); - private Integer volumeSaveState; - - public LaMetricTimeImpl(Configuration config) - { - this(config.getLocalConfig(), config.getCloudConfig()); - } - - public LaMetricTimeImpl(Configuration config, ClientBuilder clientBuilder) - { - this(config.getLocalConfig(), config.getCloudConfig(), clientBuilder); - } - - public LaMetricTimeImpl(LocalConfiguration localConfig, CloudConfiguration cloudConfig) - { - this.local = LaMetricTimeLocal.create(localConfig); - this.cloud = LaMetricTimeCloud.create(cloudConfig); - } - - public LaMetricTimeImpl(LocalConfiguration localConfig, - CloudConfiguration cloudConfig, - ClientBuilder clientBuilder) - { - this.local = LaMetricTimeLocal.create(localConfig, clientBuilder); - this.cloud = LaMetricTimeCloud.create(cloudConfig, clientBuilder); - } - - @Override - public String getVersion() - { - return local.getApi().getApiVersion(); - } - - @Override - public String notifyInfo(String message) throws NotificationCreationException - { - return notify(message, Priority.INFO, Icons.key("i1248"), Sound.NOTIFICATION, 1, 1); - } - - @Override - public String notifyWarning(String message) throws NotificationCreationException - { - return notify(message, Priority.WARNING, Icons.key("a2098"), Sound.NOTIFICATION2, 2, 2); - } - - @Override - public String notifyCritical(String message) throws NotificationCreationException - { - return notify(message, Priority.CRITICAL, Icons.key("a4787"), Sound.ALARM1, 0, 0); - } - - @Override - public String notify(String message, - Priority priority, - Icon icon, - Sound sound, - int messageRepeat, - int soundRepeat) throws NotificationCreationException - { - // @formatter:off - NotificationModel model = new NotificationModel() - .withCycles(messageRepeat) - .withFrames(Arrays.asList(new Frame().withText(message) - .withIcon(raw(icon)))); - if (sound != null) - { - model.setSound(new org.openhab.binding.lametrictime.api.local.model.Sound() - .withCategory(raw(sound.getCategory())) - .withId(raw(sound)) - .withRepeat(soundRepeat)); - } - // @formatter:on - - Notification notification = new Notification().withPriority(raw(priority)).withModel(model); - return local.createNotification(notification); - } - - @Override - public Application getClock() - { - return getApplication(CoreApps.clock()); - } - - @Override - public Application getCountdown() - { - return getApplication(CoreApps.countdown()); - } - - @Override - public Application getRadio() - { - return getApplication(CoreApps.radio()); - } - - @Override - public Application getStopwatch() - { - return getApplication(CoreApps.stopwatch()); - } - - @Override - public Application getWeather() - { - return getApplication(CoreApps.weather()); - } - - @Override - public Application getApplication(CoreApplication coreApp) - { - try - { - return getLocalApi().getApplication(coreApp.getPackageName()); - } - catch (ApplicationNotFoundException e) - { - // core apps should never throw errors - throw new RuntimeException("Failed to retrieve core application: " - + coreApp.getPackageName(), - e); - } - } - - @Override - public Application getApplication(String name) throws ApplicationNotFoundException - { - return getLocalApi().getApplication(name); - } - - @Override - public void activateApplication(CoreApplication coreApp) - { - try - { - activateApplication(getApplication(coreApp)); - } - catch (ApplicationActivationException e) - { - // core apps should never throw errors - throw new RuntimeException("Failed to activate core application: " - + coreApp.getPackageName(), - e); - } - } - - @Override - public void activateApplication(Application app) throws ApplicationActivationException - { - getLocalApi().activateApplication(app.getPackageName(), getFirstWidgetId(app)); - } - - @Override - public void activateWidget(Widget widget) throws ApplicationActivationException - { - getLocalApi().activateApplication(widget.getPackageName(), widget.getId()); - } - - @Override - public void doAction(CoreAction coreAction) - { - try - { - doAction(getApplication(coreAction.getApp()), coreAction.getAction()); - } - catch (ApplicationActionException e) - { - // core apps should never throw errors - throw new RuntimeException("Failed to execute weather forecast action", e); - } - } - - @Override - public void doAction(Application app, UpdateAction action) throws ApplicationActionException - { - getLocalApi().doAction(app.getPackageName(), getFirstWidgetId(app), action); - } - - @Override - public void doAction(Widget widget, CoreAction coreAction) throws ApplicationActionException - { - doAction(widget, coreAction.getAction()); - } - - @Override - public void doAction(Widget widget, UpdateAction action) throws ApplicationActionException - { - getLocalApi().doAction(widget.getPackageName(), widget.getId(), action); - } - - protected String getFirstWidgetId(Application app) - { - return app.getWidgets().firstKey(); - } - - @Override - public Display setBrightness(int brightness) throws UpdateException - { - return local.updateDisplay(new Display().withBrightness(brightness) - .withBrightnessMode(raw(BrightnessMode.MANUAL))); - } - - @Override - public Display setBrightnessMode(BrightnessMode mode) throws UpdateException - { - return local.updateDisplay(new Display().withBrightnessMode(raw(mode))); - } - - @Override - public Audio setVolume(int volume) throws UpdateException - { - return local.updateAudio(new Audio().withVolume(volume)); - } - - @Override - public Audio mute() throws UpdateException - { - synchronized (muteLock) - { - Audio audio = local.getAudio(); - if (audio.getVolume() == 0) - { - return audio; - } - - volumeSaveState = audio.getVolume(); - return setVolume(0); - } - } - - @Override - public Audio unmute() throws UpdateException - { - synchronized (muteLock) - { - if (volumeSaveState == null) - { - Audio audio = local.getAudio(); - if (audio.getVolume() == 0) - { - return setVolume(50); - } - else - { - return audio; - } - } - - Audio audio = setVolume(volumeSaveState); - volumeSaveState = null; - return audio; - } - } - - @Override - public Bluetooth setBluetoothActive(boolean active) throws UpdateException - { - return local.updateBluetooth(new Bluetooth().withActive(active)); - } - - @Override - public Bluetooth setBluetoothName(String name) throws UpdateException - { - return local.updateBluetooth(new Bluetooth().withName(name)); - } - - @Override - public LaMetricTimeLocal getLocalApi() - { - return local; - } - - @Override - public LaMetricTimeCloud getCloudApi() - { - return cloud; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActionException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActionException.java deleted file mode 100644 index afdce9616..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActionException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class ApplicationActionException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public ApplicationActionException() - { - super(); - } - - public ApplicationActionException(String message) - { - super(message); - } - - public ApplicationActionException(Throwable cause) - { - super(cause); - } - - public ApplicationActionException(String message, Throwable cause) - { - super(message, cause); - } - - public ApplicationActionException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public ApplicationActionException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActivationException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActivationException.java deleted file mode 100644 index 261a80f98..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationActivationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class ApplicationActivationException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public ApplicationActivationException() - { - super(); - } - - public ApplicationActivationException(String message) - { - super(message); - } - - public ApplicationActivationException(Throwable cause) - { - super(cause); - } - - public ApplicationActivationException(String message, Throwable cause) - { - super(message, cause); - } - - public ApplicationActivationException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public ApplicationActivationException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationNotFoundException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationNotFoundException.java deleted file mode 100644 index fa41f355e..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/ApplicationNotFoundException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class ApplicationNotFoundException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public ApplicationNotFoundException() - { - super(); - } - - public ApplicationNotFoundException(String message) - { - super(message); - } - - public ApplicationNotFoundException(Throwable cause) - { - super(cause); - } - - public ApplicationNotFoundException(String message, Throwable cause) - { - super(message, cause); - } - - public ApplicationNotFoundException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public ApplicationNotFoundException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeException.java deleted file mode 100644 index 30f438921..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeException.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import java.util.List; - -import org.openhab.binding.lametrictime.api.local.model.Error; -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class LaMetricTimeException extends Exception -{ - private static final long serialVersionUID = 1L; - - public LaMetricTimeException() - { - super(); - } - - public LaMetricTimeException(String message) - { - super(message); - } - - public LaMetricTimeException(Throwable cause) - { - super(cause); - } - - public LaMetricTimeException(String message, Throwable cause) - { - super(message, cause); - } - - public LaMetricTimeException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public LaMetricTimeException(Failure failure) - { - super(buildMessage(failure)); - } - - private static String buildMessage(Failure failure) - { - StringBuilder builder = new StringBuilder(); - - List errors = failure.getErrors(); - if (!errors.isEmpty()) - { - builder.append(errors.get(0).getMessage()); - } - - for (int i = 1; i < errors.size(); i++) - { - builder.append("; ").append(errors.get(i).getMessage()); - } - - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeLocal.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeLocal.java deleted file mode 100644 index 91c7e8985..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LaMetricTimeLocal.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import java.util.List; -import java.util.SortedMap; - -import javax.ws.rs.client.ClientBuilder; - -import org.openhab.binding.lametrictime.api.local.impl.LaMetricTimeLocalImpl; -import org.openhab.binding.lametrictime.api.local.model.Api; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.Device; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.Notification; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; -import org.openhab.binding.lametrictime.api.local.model.WidgetUpdates; -import org.openhab.binding.lametrictime.api.local.model.Wifi; - -public interface LaMetricTimeLocal -{ - public Api getApi(); - - public Device getDevice(); - - public String createNotification(Notification notification) throws NotificationCreationException; - - public List getNotifications(); - - public Notification getCurrentNotification(); - - public Notification getNotification(String id) throws NotificationNotFoundException; - - public void deleteNotification(String id) throws NotificationNotFoundException; - - public Display getDisplay(); - - public Display updateDisplay(Display display) throws UpdateException; - - public Audio getAudio(); - - public Audio updateAudio(Audio audio) throws UpdateException; - - public Bluetooth getBluetooth(); - - public Bluetooth updateBluetooth(Bluetooth bluetooth) throws UpdateException; - - public Wifi getWifi(); - - public void updateApplication(String packageName, - String accessToken, - WidgetUpdates widgetUpdates) throws UpdateException; - - public SortedMap getApplications(); - - public Application getApplication(String packageName) throws ApplicationNotFoundException; - - public void activatePreviousApplication(); - - public void activateNextApplication(); - - public void activateApplication(String packageName, - String widgetId) throws ApplicationActivationException; - - public void doAction(String packageName, - String widgetId, - UpdateAction action) throws ApplicationActionException; - - public static LaMetricTimeLocal create(LocalConfiguration config) - { - return new LaMetricTimeLocalImpl(config); - } - - public static LaMetricTimeLocal create(LocalConfiguration config, ClientBuilder clientBuilder) - { - return new LaMetricTimeLocalImpl(config, clientBuilder); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationCreationException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationCreationException.java deleted file mode 100644 index c07dc39fc..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationCreationException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class NotificationCreationException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public NotificationCreationException() - { - super(); - } - - public NotificationCreationException(String message) - { - super(message); - } - - public NotificationCreationException(Throwable cause) - { - super(cause); - } - - public NotificationCreationException(String message, Throwable cause) - { - super(message, cause); - } - - public NotificationCreationException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public NotificationCreationException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationNotFoundException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationNotFoundException.java deleted file mode 100644 index d34085fc9..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/NotificationNotFoundException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class NotificationNotFoundException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public NotificationNotFoundException() - { - super(); - } - - public NotificationNotFoundException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public NotificationNotFoundException(String message, Throwable cause) - { - super(message, cause); - } - - public NotificationNotFoundException(String message) - { - super(message); - } - - public NotificationNotFoundException(Throwable cause) - { - super(cause); - } - - public NotificationNotFoundException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/UpdateException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/UpdateException.java deleted file mode 100644 index 553e0a1d5..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/UpdateException.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local; - -import org.openhab.binding.lametrictime.api.local.model.Failure; - -public class UpdateException extends LaMetricTimeException -{ - private static final long serialVersionUID = 1L; - - public UpdateException() - { - super(); - } - - public UpdateException(String message) - { - super(message); - } - - public UpdateException(Throwable cause) - { - super(cause); - } - - public UpdateException(String message, Throwable cause) - { - super(message, cause); - } - - public UpdateException(String message, - Throwable cause, - boolean enableSuppression, - boolean writableStackTrace) - { - super(message, cause, enableSuppression, writableStackTrace); - } - - public UpdateException(Failure failure) - { - super(failure); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Action.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Action.java deleted file mode 100644 index d0fbe544f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Action.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import java.util.SortedMap; - -import com.google.gson.annotations.SerializedName; - -public class Action -{ - private String id; - @SerializedName("params") - private SortedMap parameters; - - public String getId() - { - return id; - } - - public void setId(String id) - { - this.id = id; - } - - public Action withId(String id) - { - setId(id); - return this; - } - - public SortedMap getParameters() - { - return parameters; - } - - public void setParameters(SortedMap parameters) - { - this.parameters = parameters; - } - - public Action withParameters(SortedMap parameters) - { - setParameters(parameters); - return this; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((parameters == null) ? 0 : parameters.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - Action other = (Action)obj; - if (id == null) - { - if (other.id != null) - { - return false; - } - } - else if (!id.equals(other.id)) - { - return false; - } - if (parameters == null) - { - if (other.parameters != null) - { - return false; - } - } - else if (!parameters.equals(other.parameters)) - { - return false; - } - return true; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Action [id="); - builder.append(id); - builder.append(", parameters="); - builder.append(parameters); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Api.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Api.java deleted file mode 100644 index 83ba2c17e..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Api.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Api -{ - private String apiVersion; - private Endpoints endpoints; - - public String getApiVersion() - { - return apiVersion; - } - - public void setApiVersion(String apiVersion) - { - this.apiVersion = apiVersion; - } - - public Api withApiVersion(String apiVersion) - { - this.apiVersion = apiVersion; - return this; - } - - public Endpoints getEndpoints() - { - return endpoints; - } - - public void setEndpoints(Endpoints endpoints) - { - this.endpoints = endpoints; - } - - public Api withEndpoints(Endpoints endpoints) - { - this.endpoints = endpoints; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Api [apiVersion="); - builder.append(apiVersion); - builder.append(", endpoints="); - builder.append(endpoints); - builder.append("]"); - return builder.toString(); - } -} \ No newline at end of file diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Audio.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Audio.java deleted file mode 100644 index 1282ad9fc..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Audio.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Audio -{ - private Integer volume; - - public Integer getVolume() - { - return volume; - } - - public void setVolume(Integer volume) - { - this.volume = volume; - } - - public Audio withVolume(Integer volume) - { - this.volume = volume; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Audio [volume="); - builder.append(volume); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/AudioUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/AudioUpdateResult.java deleted file mode 100644 index d5a5ddfbf..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/AudioUpdateResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class AudioUpdateResult -{ - private Success success; - - public Success getSuccess() - { - return success; - } - - public void setSuccess(Success success) - { - this.success = success; - } - - public AudioUpdateResult withSuccess(Success success) - { - this.success = success; - return this; - } - - public static class Success - { - private Audio data; - - public Audio getData() - { - return data; - } - - public void setData(Audio data) - { - this.data = data; - } - - public Success withData(Audio data) - { - this.data = data; - return this; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BluetoothUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BluetoothUpdateResult.java deleted file mode 100644 index a28b78781..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BluetoothUpdateResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class BluetoothUpdateResult -{ - private Success success; - - public Success getSuccess() - { - return success; - } - - public void setSuccess(Success success) - { - this.success = success; - } - - public BluetoothUpdateResult withSuccess(Success success) - { - this.success = success; - return this; - } - - public static class Success - { - private Bluetooth data; - - public Bluetooth getData() - { - return data; - } - - public void setData(Bluetooth data) - { - this.data = data; - } - - public Success withData(Bluetooth data) - { - this.data = data; - return this; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BooleanParameter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BooleanParameter.java deleted file mode 100644 index cb3c3f2b4..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/BooleanParameter.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class BooleanParameter extends Parameter -{ - private Boolean value; - - @Override - public BooleanParameter withName(String name) - { - super.withName(name); - return this; - } - - @Override - public BooleanParameter withRequired(Boolean required) - { - super.withRequired(required); - return this; - } - - public Boolean getValue() - { - return value; - } - - public void setValue(Boolean value) - { - this.value = value; - } - - public BooleanParameter withValue(Boolean value) - { - setValue(value); - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("BooleanParameter [value="); - builder.append(value); - builder.append(", getName()="); - builder.append(getName()); - builder.append(", getRequired()="); - builder.append(getRequired()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Display.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Display.java deleted file mode 100644 index 057812a32..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Display.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Display -{ - private Integer brightness; - private String brightnessMode; - private Integer height; - private Screensaver screensaver; - private String type; - private Integer width; - - public Integer getBrightness() - { - return brightness; - } - - public void setBrightness(Integer brightness) - { - this.brightness = brightness; - } - - public Display withBrightness(Integer brightness) - { - this.brightness = brightness; - return this; - } - - public String getBrightnessMode() - { - return brightnessMode; - } - - public void setBrightnessMode(String brightnessMode) - { - this.brightnessMode = brightnessMode; - } - - public Display withBrightnessMode(String brightnessMode) - { - this.brightnessMode = brightnessMode; - return this; - } - - public Integer getHeight() - { - return height; - } - - public void setHeight(Integer height) - { - this.height = height; - } - - public Display withHeight(Integer height) - { - this.height = height; - return this; - } - - public Screensaver getScreensaver() - { - return screensaver; - } - - public void setScreensaver(Screensaver screensaver) - { - this.screensaver = screensaver; - } - - public Display withScreensaver(Screensaver screensaver) - { - this.screensaver = screensaver; - return this; - } - - public String getType() - { - return type; - } - - public void setType(String type) - { - this.type = type; - } - - public Display withType(String type) - { - this.type = type; - return this; - } - - public Integer getWidth() - { - return width; - } - - public void setWidth(Integer width) - { - this.width = width; - } - - public Display withWidth(Integer width) - { - this.width = width; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Display [brightness="); - builder.append(brightness); - builder.append(", brightnessMode="); - builder.append(brightnessMode); - builder.append(", height="); - builder.append(height); - builder.append(", screensaver="); - builder.append(screensaver); - builder.append(", type="); - builder.append(type); - builder.append(", width="); - builder.append(width); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/DisplayUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/DisplayUpdateResult.java deleted file mode 100644 index 948ade75b..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/DisplayUpdateResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class DisplayUpdateResult -{ - private Success success; - - public Success getSuccess() - { - return success; - } - - public void setSuccess(Success success) - { - this.success = success; - } - - public DisplayUpdateResult withSuccess(Success success) - { - this.success = success; - return this; - } - - public static class Success - { - private Display data; - - public Display getData() - { - return data; - } - - public void setData(Display data) - { - this.data = data; - } - - public Success withData(Display data) - { - this.data = data; - return this; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Error.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Error.java deleted file mode 100644 index d37b7b5bd..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Error.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Error -{ - private String message; - - public String getMessage() - { - return message; - } - - public void setMessage(String message) - { - this.message = message; - } - - public Error withMessage(String message) - { - this.message = message; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Error [message="); - builder.append(message); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Failure.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Failure.java deleted file mode 100644 index 32b5b3d3f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Failure.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import java.util.ArrayList; -import java.util.List; - -public class Failure -{ - private List errors = new ArrayList(); - - public List getErrors() - { - return errors; - } - - public void setErrors(List errors) - { - this.errors = errors; - } - - public Failure withErrors(List errors) - { - this.errors = errors; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Failure [errors="); - builder.append(errors); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/GoalData.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/GoalData.java deleted file mode 100644 index 6a9d04b74..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/GoalData.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class GoalData -{ - private Integer start; - private Integer current; - private Integer end; - private String unit; - - public Integer getStart() - { - return start; - } - - public void setStart(Integer start) - { - this.start = start; - } - - public GoalData withStart(Integer start) - { - this.start = start; - return this; - } - - public Integer getCurrent() - { - return current; - } - - public void setCurrent(Integer current) - { - this.current = current; - } - - public GoalData withCurrent(Integer current) - { - this.current = current; - return this; - } - - public Integer getEnd() - { - return end; - } - - public void setEnd(Integer end) - { - this.end = end; - } - - public GoalData withEnd(Integer end) - { - this.end = end; - return this; - } - - public String getUnit() - { - return unit; - } - - public void setUnit(String unit) - { - this.unit = unit; - } - - public GoalData withUnit(String unit) - { - this.unit = unit; - return this; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((current == null) ? 0 : current.hashCode()); - result = prime * result + ((end == null) ? 0 : end.hashCode()); - result = prime * result + ((start == null) ? 0 : start.hashCode()); - result = prime * result + ((unit == null) ? 0 : unit.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) - { - if (this == obj) - { - return true; - } - if (obj == null) - { - return false; - } - if (getClass() != obj.getClass()) - { - return false; - } - GoalData other = (GoalData)obj; - if (current == null) - { - if (other.current != null) - { - return false; - } - } - else if (!current.equals(other.current)) - { - return false; - } - if (end == null) - { - if (other.end != null) - { - return false; - } - } - else if (!end.equals(other.end)) - { - return false; - } - if (start == null) - { - if (other.start != null) - { - return false; - } - } - else if (!start.equals(other.start)) - { - return false; - } - if (unit == null) - { - if (other.unit != null) - { - return false; - } - } - else if (!unit.equals(other.unit)) - { - return false; - } - return true; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("GoalData [start="); - builder.append(start); - builder.append(", current="); - builder.append(current); - builder.append(", end="); - builder.append(end); - builder.append(", unit="); - builder.append(unit); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/IntegerParameter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/IntegerParameter.java deleted file mode 100644 index 6f351829f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/IntegerParameter.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class IntegerParameter extends Parameter -{ - private Integer value; - - @Override - public IntegerParameter withName(String name) - { - super.withName(name); - return this; - } - - @Override - public IntegerParameter withRequired(Boolean required) - { - super.withRequired(required); - return this; - } - - public Integer getValue() - { - return value; - } - - public void setValue(Integer value) - { - this.value = value; - } - - public IntegerParameter withValue(Integer value) - { - setValue(value); - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("IntegerParameter [value="); - builder.append(value); - builder.append(", getName()="); - builder.append(getName()); - builder.append(", getRequired()="); - builder.append(getRequired()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Modes.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Modes.java deleted file mode 100644 index eb73595d0..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Modes.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Modes -{ - private TimeBased timeBased; - private WhenDark whenDark; - - public TimeBased getTimeBased() - { - return timeBased; - } - - public void setTimeBased(TimeBased timeBased) - { - this.timeBased = timeBased; - } - - public Modes withTimeBased(TimeBased timeBased) - { - this.timeBased = timeBased; - return this; - } - - public WhenDark getWhenDark() - { - return whenDark; - } - - public void setWhenDark(WhenDark whenDark) - { - this.whenDark = whenDark; - } - - public Modes withWhenDark(WhenDark whenDark) - { - this.whenDark = whenDark; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Modes [timeBased="); - builder.append(timeBased); - builder.append(", whenDark="); - builder.append(whenDark); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationModel.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationModel.java deleted file mode 100644 index 48d5936a2..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationModel.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import java.util.List; - -public class NotificationModel -{ - private Integer cycles; - private List frames; - private Sound sound; - - public Integer getCycles() - { - return cycles; - } - - public void setCycles(Integer cycles) - { - this.cycles = cycles; - } - - public NotificationModel withCycles(Integer cycles) - { - this.cycles = cycles; - return this; - } - - public List getFrames() - { - return frames; - } - - public void setFrames(List frames) - { - this.frames = frames; - } - - public NotificationModel withFrames(List frames) - { - this.frames = frames; - return this; - } - - public Sound getSound() - { - return sound; - } - - public void setSound(Sound sound) - { - this.sound = sound; - } - - public NotificationModel withSound(Sound sound) - { - this.sound = sound; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("NotificationModel [cycles="); - builder.append(cycles); - builder.append(", frames="); - builder.append(frames); - builder.append(", sound="); - builder.append(sound); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationResult.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationResult.java deleted file mode 100644 index 6e1ecc6bd..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/NotificationResult.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class NotificationResult -{ - private Success success; - - public Success getSuccess() - { - return success; - } - - public void setSuccess(Success success) - { - this.success = success; - } - - public NotificationResult withSuccess(Success success) - { - this.success = success; - return this; - } - - public static class Success - { - private String id; - - public String getId() - { - return id; - } - - public void setId(String id) - { - this.id = id; - } - - public Success withId(String id) - { - this.id = id; - return this; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Parameter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Parameter.java deleted file mode 100644 index 38afe7fee..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Parameter.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public abstract class Parameter -{ - private String name; - private Boolean required; - - public String getName() - { - return name; - } - - public void setName(String name) - { - this.name = name; - } - - public Parameter withName(String name) - { - setName(name); - return this; - } - - public Boolean getRequired() - { - return required; - } - - public void setRequired(Boolean required) - { - this.required = required; - } - - public Parameter withRequired(Boolean required) - { - setRequired(required); - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Screensaver.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Screensaver.java deleted file mode 100644 index 923cb2205..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Screensaver.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Screensaver -{ - private Boolean enabled; - private Modes modes; - private String widget; - - public Boolean isEnabled() - { - return enabled; - } - - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - public Screensaver withEnabled(Boolean enabled) - { - this.enabled = enabled; - return this; - } - - public Modes getModes() - { - return modes; - } - - public void setModes(Modes modes) - { - this.modes = modes; - } - - public Screensaver withModes(Modes modes) - { - this.modes = modes; - return this; - } - - public String getWidget() - { - return widget; - } - - public void setWidget(String widget) - { - this.widget = widget; - } - - public Screensaver withWidget(String widget) - { - this.widget = widget; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Screensaver [enabled="); - builder.append(enabled); - builder.append(", modes="); - builder.append(modes); - builder.append(", widget="); - builder.append(widget); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Sound.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Sound.java deleted file mode 100644 index e0fe6343e..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Sound.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class Sound -{ - private String category; - private String id; - private Integer repeat; - - public String getCategory() - { - return category; - } - - public void setCategory(String category) - { - this.category = category; - } - - public Sound withCategory(String category) - { - this.category = category; - return this; - } - - public String getId() - { - return id; - } - - public void setId(String id) - { - this.id = id; - } - - public Sound withId(String id) - { - this.id = id; - return this; - } - - public Integer getRepeat() - { - return repeat; - } - - public void setRepeat(Integer repeat) - { - this.repeat = repeat; - } - - public Sound withRepeat(Integer repeat) - { - this.repeat = repeat; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("Sound [category="); - builder.append(category); - builder.append(", id="); - builder.append(id); - builder.append(", repeat="); - builder.append(repeat); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/StringParameter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/StringParameter.java deleted file mode 100644 index 502914938..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/StringParameter.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class StringParameter extends Parameter -{ - private String format; - private String value; - - @Override - public StringParameter withName(String name) - { - super.withName(name); - return this; - } - - @Override - public StringParameter withRequired(Boolean required) - { - super.withRequired(required); - return this; - } - - public String getFormat() - { - return format; - } - - public void setFormat(String format) - { - this.format = format; - } - - public StringParameter withFormat(String format) - { - setFormat(format); - return this; - } - - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - public StringParameter withValue(String value) - { - setValue(value); - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("StringParameter [format="); - builder.append(format); - builder.append(", value="); - builder.append(value); - builder.append(", getName()="); - builder.append(getName()); - builder.append(", getRequired()="); - builder.append(getRequired()); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/TimeBased.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/TimeBased.java deleted file mode 100644 index 59e8ca134..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/TimeBased.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class TimeBased -{ - private Boolean enabled; - - public Boolean isEnabled() - { - return enabled; - } - - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - public TimeBased withEnabled(Boolean enabled) - { - this.enabled = enabled; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("TimeBased [enabled="); - builder.append(enabled); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/UpdateAction.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/UpdateAction.java deleted file mode 100644 index c7428a6d1..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/UpdateAction.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import java.util.SortedMap; - -public class UpdateAction extends Action -{ - @Override - public UpdateAction withId(String id) - { - super.setId(id); - return this; - } - - @Override - public UpdateAction withParameters(SortedMap parameters) - { - super.setParameters(parameters); - return this; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WhenDark.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WhenDark.java deleted file mode 100644 index b3c87dadc..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WhenDark.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -public class WhenDark -{ - private Boolean enabled; - - public Boolean isEnabled() - { - return enabled; - } - - public void setEnabled(Boolean enabled) - { - this.enabled = enabled; - } - - public WhenDark withEnabled(Boolean enabled) - { - this.enabled = enabled; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("WhenDark [enabled="); - builder.append(enabled); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WidgetUpdates.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WidgetUpdates.java deleted file mode 100644 index a3c9fd10b..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/WidgetUpdates.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import java.util.List; - -public class WidgetUpdates -{ - private List frames; - - public List getFrames() - { - return frames; - } - - public void setFrames(List frames) - { - this.frames = frames; - } - - public WidgetUpdates withFrames(List frames) - { - this.frames = frames; - return this; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append("WidgetUpdates [frames="); - builder.append(frames); - builder.append("]"); - return builder.toString(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ApiValue.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ApiValue.java deleted file mode 100644 index 30df5532f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ApiValue.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -public interface ApiValue -{ - public String toRaw(); - - public static String raw(ApiValue value) - { - if (value == null) - { - return null; - } - - return value.toRaw(); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ClockApp.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ClockApp.java deleted file mode 100644 index 2483e00ad..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/ClockApp.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.SortedMap; -import java.util.TreeMap; - -import org.openhab.binding.lametrictime.api.local.model.BooleanParameter; -import org.openhab.binding.lametrictime.api.local.model.Parameter; -import org.openhab.binding.lametrictime.api.local.model.StringParameter; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class ClockApp extends CoreApplication -{ - private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss"); - - private static final String NAME = "com.lametric.clock"; - - private static final String ACTION_ALARM = "clock.alarm"; - - private static final String PARAMETER_ENABLED = "enabled"; - private static final String PARAMETER_TIME = "time"; - private static final String PARAMETER_WAKE_WITH_RADIO = "wake_with_radio"; - - public ClockApp() - { - super(NAME); - } - - public CoreAction setAlarm(Boolean enabled, LocalTime time, Boolean wakeWithRadio) - { - SortedMap parameters = new TreeMap<>(); - - if (enabled != null) - { - parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(enabled)); - } - - if (time != null) - { - parameters.put(PARAMETER_TIME, - new StringParameter().withValue(time.format(TIME_FORMATTER))); - } - - if (wakeWithRadio != null) - { - parameters.put(PARAMETER_WAKE_WITH_RADIO, - new BooleanParameter().withValue(wakeWithRadio)); - } - - return new CoreAction(this, - new UpdateAction().withId(ACTION_ALARM).withParameters(parameters)); - } - - public CoreAction stopAlarm() - { - SortedMap parameters = new TreeMap<>(); - parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(false)); - - return new CoreAction(this, - new UpdateAction().withId(ACTION_ALARM).withParameters(parameters)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreAction.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreAction.java deleted file mode 100644 index d183cadb8..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreAction.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class CoreAction -{ - private final CoreApplication app; - private final UpdateAction action; - - protected CoreAction(CoreApplication app, UpdateAction action) - { - this.app = app; - this.action = action; - } - - public CoreApplication getApp() - { - return app; - } - - public UpdateAction getAction() - { - return action; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApplication.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApplication.java deleted file mode 100644 index c01f80951..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApplication.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -public abstract class CoreApplication -{ - private final String packageName; - - public CoreApplication(String packageName) - { - this.packageName = packageName; - } - - public String getPackageName() - { - return packageName; - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApps.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApps.java deleted file mode 100644 index 1f38542da..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CoreApps.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -public class CoreApps -{ - private static final ClockApp CLOCK = new ClockApp(); - private static final CountdownApp COUNTDOWN = new CountdownApp(); - private static final RadioApp RADIO = new RadioApp(); - private static final StopwatchApp STOPWATCH = new StopwatchApp(); - private static final WeatherApp WEATHER = new WeatherApp(); - - public static ClockApp clock() - { - return CLOCK; - } - - public static CountdownApp countdown() - { - return COUNTDOWN; - } - - public static RadioApp radio() - { - return RADIO; - } - - public static StopwatchApp stopwatch() - { - return STOPWATCH; - } - - public static WeatherApp weather() - { - return WEATHER; - } - - // @formatter:off - private CoreApps() {} - // @formatter:on -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CountdownApp.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CountdownApp.java deleted file mode 100644 index 972df76d6..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/CountdownApp.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import java.util.SortedMap; -import java.util.TreeMap; - -import org.openhab.binding.lametrictime.api.local.model.BooleanParameter; -import org.openhab.binding.lametrictime.api.local.model.IntegerParameter; -import org.openhab.binding.lametrictime.api.local.model.Parameter; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class CountdownApp extends CoreApplication -{ - private static final String NAME = "com.lametric.countdown"; - - private static final String ACTION_CONFIGURE = "countdown.configure"; - private static final String ACTION_PAUSE = "countdown.pause"; - private static final String ACTION_RESET = "countdown.reset"; - private static final String ACTION_START = "countdown.start"; - - private static final String PARAMETER_DURATION = "duration"; - private static final String PARAMETER_START_NOW = "start_now"; - - public CountdownApp() - { - super(NAME); - } - - public CoreAction configure(int duration, boolean startNow) - { - SortedMap parameters = new TreeMap<>(); - parameters.put(PARAMETER_DURATION, new IntegerParameter().withValue(duration)); - parameters.put(PARAMETER_START_NOW, new BooleanParameter().withValue(startNow)); - - return new CoreAction(this, - new UpdateAction().withId(ACTION_CONFIGURE) - .withParameters(parameters)); - } - - public CoreAction pause() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE)); - } - - public CoreAction reset() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_RESET)); - } - - public CoreAction start() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_START)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icon.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icon.java deleted file mode 100644 index c25f3f37c..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icon.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -public interface Icon extends ApiValue -{ - // marker interface -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/RadioApp.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/RadioApp.java deleted file mode 100644 index 41cac5480..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/RadioApp.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class RadioApp extends CoreApplication -{ - private static final String NAME = "com.lametric.radio"; - - private static final String ACTION_NEXT = "radio.next"; - private static final String ACTION_PLAY = "radio.play"; - private static final String ACTION_PREV = "radio.prev"; - private static final String ACTION_STOP = "radio.stop"; - - public RadioApp() - { - super(NAME); - } - - public CoreAction next() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_NEXT)); - } - - public CoreAction play() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_PLAY)); - } - - public CoreAction previous() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_PREV)); - } - - public CoreAction stop() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_STOP)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/StopwatchApp.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/StopwatchApp.java deleted file mode 100644 index 2af8f4873..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/StopwatchApp.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class StopwatchApp extends CoreApplication -{ - private static final String NAME = "com.lametric.stopwatch"; - - private static final String ACTION_PAUSE = "stopwatch.pause"; - private static final String ACTION_RESET = "stopwatch.reset"; - private static final String ACTION_START = "stopwatch.start"; - - public StopwatchApp() - { - super(NAME); - } - - public CoreAction pause() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE)); - } - - public CoreAction reset() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_RESET)); - } - - public CoreAction start() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_START)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/WeatherApp.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/WeatherApp.java deleted file mode 100644 index 8db4088fa..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/WeatherApp.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model; - -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; - -public class WeatherApp extends CoreApplication -{ - private static final String NAME = "com.lametric.weather"; - - private static final String ACTION_FORECAST = "weather.forecast"; - - public WeatherApp() - { - super(NAME); - } - - public CoreAction forecast() - { - return new CoreAction(this, new UpdateAction().withId(ACTION_FORECAST)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/BrightnessMode.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/BrightnessMode.java deleted file mode 100644 index be764da19..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/BrightnessMode.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum BrightnessMode implements ApiValue -{ - AUTO, - MANUAL; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static BrightnessMode toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/DisplayType.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/DisplayType.java deleted file mode 100644 index ada22e4ed..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/DisplayType.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum DisplayType implements ApiValue -{ - MONOCHROME, - GRAYSCALE, - COLOR, - MIXED; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static DisplayType toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IconType.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IconType.java deleted file mode 100644 index 13f43accf..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IconType.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum IconType implements ApiValue -{ - NONE, - INFO, - ALERT; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static IconType toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IpMode.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IpMode.java deleted file mode 100644 index bdc3630f9..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/IpMode.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum IpMode implements ApiValue -{ - STATIC, - DHCP; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static IpMode toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Priority.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Priority.java deleted file mode 100644 index bb9cfebbf..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Priority.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum Priority implements ApiValue -{ - INFO, - WARNING, - CRITICAL; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static Priority toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/SoundCategory.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/SoundCategory.java deleted file mode 100644 index d1684ed41..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/SoundCategory.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum SoundCategory implements ApiValue -{ - NOTIFICATIONS, - ALARMS; - - @Override - public String toRaw() - { - return name().toLowerCase(); - } - - public static SoundCategory toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/WifiEncryption.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/WifiEncryption.java deleted file mode 100644 index e28a6763f..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/WifiEncryption.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import org.openhab.binding.lametrictime.api.model.ApiValue; - -public enum WifiEncryption implements ApiValue -{ - OPEN, - WEP, - WPA, - WPA2; - - @Override - public String toRaw() - { - return name(); - } - - public static WifiEncryption toEnum(String raw) - { - if (raw == null) - { - return null; - } - - try - { - return valueOf(raw); - } - catch (IllegalArgumentException e) - { - // not a valid raw string - return null; - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/BasicAuthenticator.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/BasicAuthenticator.java similarity index 98% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/BasicAuthenticator.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/BasicAuthenticator.java index 3756a9045..c5ec2b602 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/BasicAuthenticator.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/BasicAuthenticator.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.openhab.binding.lametrictime.api.authentication; +package org.openhab.binding.lametrictime.internal.api.authentication; import java.util.Base64; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFeature.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFeature.java similarity index 99% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFeature.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFeature.java index 6e6027c26..bc40e815b 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFeature.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFeature.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.openhab.binding.lametrictime.api.authentication; +package org.openhab.binding.lametrictime.internal.api.authentication; import javax.ws.rs.core.Feature; import javax.ws.rs.core.FeatureContext; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFilter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFilter.java similarity index 99% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFilter.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFilter.java index c61c0293a..f457624d8 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/HttpAuthenticationFilter.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/HttpAuthenticationFilter.java @@ -37,8 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ - -package org.openhab.binding.lametrictime.api.authentication; +package org.openhab.binding.lametrictime.internal.api.authentication; import java.io.IOException; import java.io.InputStream; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/RequestAuthenticationException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/RequestAuthenticationException.java similarity index 97% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/RequestAuthenticationException.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/RequestAuthenticationException.java index adbb9bfbd..9d42feaa3 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/RequestAuthenticationException.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/RequestAuthenticationException.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.openhab.binding.lametrictime.api.authentication; +package org.openhab.binding.lametrictime.internal.api.authentication; import javax.ws.rs.ProcessingException; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/ResponseAuthenticationException.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/ResponseAuthenticationException.java similarity index 97% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/ResponseAuthenticationException.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/ResponseAuthenticationException.java index 03fa4aa86..d71f2d0cd 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/authentication/ResponseAuthenticationException.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/authentication/ResponseAuthenticationException.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.openhab.binding.lametrictime.api.authentication; +package org.openhab.binding.lametrictime.internal.api.authentication; import javax.ws.rs.client.ResponseProcessingException; import javax.ws.rs.core.Response; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/filter/LoggingFilter.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/filter/LoggingFilter.java similarity index 99% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/filter/LoggingFilter.java rename to bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/filter/LoggingFilter.java index 7b355cbd2..f57ea2077 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/filter/LoggingFilter.java +++ b/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/internal/api/filter/LoggingFilter.java @@ -37,7 +37,7 @@ * only if the new code is made subject to such option by the copyright * holder. */ -package org.openhab.binding.lametrictime.api.filter; +package org.openhab.binding.lametrictime.internal.api.filter; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllIntegrationTestsSuite.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllIntegrationTestsSuite.java deleted file mode 100644 index 6c5ae8e7c..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllIntegrationTestsSuite.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api; - -import org.junit.runner.RunWith; - -import com.googlecode.junittoolbox.SuiteClasses; -import com.googlecode.junittoolbox.WildcardPatternSuite; - -@RunWith(WildcardPatternSuite.class) -@SuiteClasses({ "**/*IT.class" }) -public class AllIntegrationTestsSuite -{ - // Execute all integration tests -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllUnitTestsSuite.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllUnitTestsSuite.java deleted file mode 100644 index d85021cbf..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/AllUnitTestsSuite.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api; - -import org.junit.runner.RunWith; - -import com.googlecode.junittoolbox.ParallelSuite; -import com.googlecode.junittoolbox.SuiteClasses; - -@RunWith(ParallelSuite.class) -@SuiteClasses({ "**/*Test.class" }) -public class AllUnitTestsSuite { - // Execute all unit tests -} \ No newline at end of file diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/impl/FileIconTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/impl/FileIconTest.java deleted file mode 100644 index beca8b434..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/impl/FileIconTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.impl; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.test.AbstractTest; - -public class FileIconTest extends AbstractTest -{ - @Test - public void testLocalPathGif() - { - FileIcon icon = new FileIcon(getTestDataPath("smile.gif")); - assertEquals("data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7", - icon.toRaw()); - } - - @Test - public void testLocalPathPng() - { - FileIcon icon = new FileIcon(getTestDataPath("info.png")); - assertEquals("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=", - icon.toRaw()); - } - - @Test - public void testLocalFileGif() - { - FileIcon icon = new FileIcon(getTestDataFile("smile.gif")); - assertEquals("data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7", - icon.toRaw()); - } - - @Test - public void testLocalFilePng() - { - FileIcon icon = new FileIcon(getTestDataFile("info.png")); - assertEquals("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=", - icon.toRaw()); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/AudioTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/AudioTest.java deleted file mode 100644 index d44394f2b..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/AudioTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.FileReader; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; - -import com.google.gson.Gson; - -public class AudioTest extends AbstractTest -{ - private static Gson gson; - - @BeforeAll - public static void setUpBeforeClass() - { - gson = GsonGenerator.create(true); - } - - @Test - public void testSerializeAllFields() throws Exception - { - Audio audio = new Audio().withVolume(42); - assertEquals(readJson("audio.json"), gson.toJson(audio)); - } - - @Test - public void testDeserializeAllFields() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("audio.json"))) - { - Audio audio = gson.fromJson(reader, Audio.class); - assertEquals(Integer.valueOf(42), audio.getVolume()); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/BluetoothTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/BluetoothTest.java deleted file mode 100644 index b9de4e496..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/BluetoothTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.FileReader; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; - -import com.google.gson.Gson; - -public class BluetoothTest extends AbstractTest -{ - private static Gson gson; - - @BeforeAll - public static void setUpBeforeClass() - { - gson = GsonGenerator.create(true); - } - - @Test - public void testSerializeAllFields() throws Exception - { - Bluetooth bluetooth = new Bluetooth().withActive(false) - .withAvailable(true) - .withDiscoverable(false) - .withMac("AA:AA:AA:AA:AA:AA") - .withName("LM9999") - .withPairable(true); - assertEquals(readJson("bluetooth-mac-address.json"), gson.toJson(bluetooth)); - } - - @Test - public void testDeserializeMac() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("bluetooth-mac.json"))) - { - Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class); - assertEquals(false, bluetooth.isActive()); - assertEquals(true, bluetooth.isAvailable()); - assertEquals(false, bluetooth.isDiscoverable()); - assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac()); - assertEquals("LM9999", bluetooth.getName()); - assertEquals(true, bluetooth.isPairable()); - } - } - - @Test - public void testDeserializeAddress() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("bluetooth-address.json"))) - { - Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class); - assertEquals(false, bluetooth.isActive()); - assertEquals(true, bluetooth.isAvailable()); - assertEquals(false, bluetooth.isDiscoverable()); - assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac()); - assertEquals("LM9999", bluetooth.getName()); - assertEquals(true, bluetooth.isPairable()); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/GoalDataTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/GoalDataTest.java deleted file mode 100644 index 1324688ba..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/GoalDataTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.FileReader; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; - -import com.google.gson.Gson; - -public class GoalDataTest extends AbstractTest -{ - private static Gson gson; - - @BeforeAll - public static void setUpBeforeClass() - { - gson = GsonGenerator.create(true); - } - - @Test - public void testSerializeSimple() throws Exception - { - GoalData goalData = new GoalData().withStart(0).withEnd(100).withCurrent(50).withUnit("%"); - assertEquals(readJson("goal-data.json"), gson.toJson(goalData)); - } - - @Test - public void testDeserializeSimple() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("goal-data.json"))) - { - GoalData goalData = gson.fromJson(reader, GoalData.class); - assertEquals(Integer.valueOf(0), goalData.getStart()); - assertEquals(Integer.valueOf(100), goalData.getEnd()); - assertEquals(Integer.valueOf(50), goalData.getCurrent()); - assertEquals("%", goalData.getUnit()); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetTest.java deleted file mode 100644 index b3dc05e60..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.local.model; - -import static org.junit.jupiter.api.Assertions.*; - -import java.io.FileReader; -import java.util.HashMap; - -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; - -import com.google.gson.Gson; -import com.google.gson.JsonPrimitive; - -public class WidgetTest extends AbstractTest -{ - private static Gson gson; - - @BeforeAll - public static void setUpBeforeClass() - { - gson = GsonGenerator.create(true); - } - - @Test - @SuppressWarnings("serial") - public void testSerialize() throws Exception - { - Widget widget = new Widget().withPackageName("com.lametric.radio") - .withIndex(Integer.valueOf(-1)) - .withSettings(new HashMap() - { - { - put("_title", new JsonPrimitive("Radio")); - } - }); - assertEquals(readJson("widget.json"), gson.toJson(widget)); - } - - @Test - @SuppressWarnings("serial") - public void testDeserialize() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("widget.json"))) - { - Widget widget = gson.fromJson(reader, Widget.class); - assertEquals("com.lametric.radio", widget.getPackageName()); - assertEquals(Integer.valueOf(-1), widget.getIndex()); - assertEquals(new HashMap() - { - { - put("_title", new JsonPrimitive("Radio")); - } - }, widget.getSettings()); - } - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/BrightnessModeTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/BrightnessModeTest.java deleted file mode 100644 index d65608dc2..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/BrightnessModeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class BrightnessModeTest { - @Test - public void testConversion() { - for (BrightnessMode value : BrightnessMode.values()) { - assertEquals(value, BrightnessMode.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(BrightnessMode.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(BrightnessMode.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/DisplayTypeTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/DisplayTypeTest.java deleted file mode 100644 index bfdd90770..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/DisplayTypeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class DisplayTypeTest { - @Test - public void testConversion() { - for (DisplayType value : DisplayType.values()) { - assertEquals(value, DisplayType.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(DisplayType.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(DisplayType.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IconTypeTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IconTypeTest.java deleted file mode 100644 index 5bba62567..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IconTypeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class IconTypeTest { - @Test - public void testConversion() { - for (IconType value : IconType.values()) { - assertEquals(value, IconType.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(IconType.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(IconType.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IpModeTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IpModeTest.java deleted file mode 100644 index 9598236e1..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/IpModeTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class IpModeTest { - @Test - public void testConversion() { - for (IpMode value : IpMode.values()) { - assertEquals(value, IpMode.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(IpMode.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(IpMode.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/PriorityTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/PriorityTest.java deleted file mode 100644 index c6ff15237..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/PriorityTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class PriorityTest { - @Test - public void testConversion() { - for (Priority value : Priority.values()) { - assertEquals(value, Priority.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(Priority.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(Priority.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundCategoryTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundCategoryTest.java deleted file mode 100644 index bef0a94b0..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundCategoryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class SoundCategoryTest { - @Test - public void testConversion() { - for (SoundCategory value : SoundCategory.values()) { - assertEquals(value, SoundCategory.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(SoundCategory.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(SoundCategory.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundTest.java deleted file mode 100644 index 1e3c89549..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/SoundTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class SoundTest { - @Test - public void testConversion() { - for (Sound value : Sound.values()) { - assertEquals(value, Sound.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(Sound.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(Sound.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/WifiEncryptionTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/WifiEncryptionTest.java deleted file mode 100644 index 724efeec9..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/model/enums/WifiEncryptionTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.model.enums; - -import static org.junit.jupiter.api.Assertions.*; - -import org.junit.jupiter.api.Test; - -public class WifiEncryptionTest { - @Test - public void testConversion() { - for (WifiEncryption value : WifiEncryption.values()) { - assertEquals(value, WifiEncryption.toEnum(value.toRaw())); - } - } - - @Test - public void testInvalidRawValue() { - assertNull(WifiEncryption.toEnum("invalid raw value")); - } - - @Test - public void testNullRawValue() { - assertNull(WifiEncryption.toEnum(null)); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/AbstractTest.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/AbstractTest.java deleted file mode 100644 index 18b0f8148..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/AbstractTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.test; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public abstract class AbstractTest { - protected File getTestDataFile(String name) { - return getTestDataPath(name).toFile(); - } - - protected Path getTestDataPath(String name) { - return TestUtil.getTestDataPath(this.getClass(), name); - } - - protected String readJson(String jsonFileName) throws IOException { - return String.join("\n", Files.readAllLines(getTestDataPath(jsonFileName))); - } -} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/TestUtil.java b/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/TestUtil.java deleted file mode 100644 index 1862e62a5..000000000 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/test/TestUtil.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2017-2018 Gregory Moyer and contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.openhab.binding.lametrictime.api.test; - -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class TestUtil -{ - private static final String RESOURCES_PATH = "src/test/resources/"; - - public static Path getTestDataPath(Class clazz, String name) - { - String packageName = clazz.getPackage().getName(); - - List paths = new ArrayList<>(); - paths.addAll(Arrays.asList(packageName.split("\\."))); - paths.add(name); - - return Paths.get(RESOURCES_PATH, paths.toArray(new String[paths.size()])); - } - - // @formatter:off - private TestUtil() {} - // @formatter:on -} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/GsonProvider.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/GsonProvider.java index 83dd5bdcb..99d905416 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/GsonProvider.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/GsonProvider.java @@ -29,7 +29,8 @@ import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; import org.osgi.service.component.annotations.Component; import com.google.gson.Gson; @@ -54,18 +55,21 @@ public class GsonProvider implements MessageBodyReader, MessageBodyWriter< } @Override - public long getSize(T t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { + public long getSize(T t, @Nullable Class type, @Nullable Type genericType, Annotation @Nullable [] annotations, + @Nullable MediaType mediaType) { return -1; } @Override - public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { + public boolean isWriteable(@Nullable Class type, @Nullable Type genericType, Annotation @Nullable [] annotations, + @Nullable MediaType mediaType) { return true; } @Override - public void writeTo(T object, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, OutputStream entityStream) + public void writeTo(T object, @Nullable Class type, @Nullable Type genericType, + Annotation @Nullable [] annotations, @Nullable MediaType mediaType, + @Nullable MultivaluedMap httpHeaders, @Nullable OutputStream entityStream) throws IOException, WebApplicationException { try (OutputStream stream = entityStream) { entityStream.write(gson.toJson(object).getBytes(StandardCharsets.UTF_8)); @@ -74,14 +78,15 @@ public class GsonProvider implements MessageBodyReader, MessageBodyWriter< } @Override - public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { + public boolean isReadable(@Nullable Class type, @Nullable Type genericType, Annotation @Nullable [] annotations, + @Nullable MediaType mediaType) { return true; } @Override - public T readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, - MultivaluedMap httpHeaders, InputStream entityStream) - throws IOException, WebApplicationException { + public T readFrom(@Nullable Class type, @Nullable Type genericType, Annotation @Nullable [] annotations, + @Nullable MediaType mediaType, @Nullable MultivaluedMap httpHeaders, + @Nullable InputStream entityStream) throws IOException, WebApplicationException { try (InputStreamReader reader = new InputStreamReader(entityStream, StandardCharsets.UTF_8)) { return gson.fromJson(reader, type); } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeConfigStatusMessage.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeConfigStatusMessage.java index 5a2c2724a..ca40a7da7 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeConfigStatusMessage.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeConfigStatusMessage.java @@ -12,11 +12,14 @@ */ package org.openhab.binding.lametrictime.internal; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * The {@link LaMetricTimeConfigStatusMessage} defines the keys to be used for configuration status messages. * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class LaMetricTimeConfigStatusMessage { public static final String HOST_MISSING = "missing-host-configuration"; public static final String API_KEY_MISSING = "missing-api-key-configuration"; diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeUtil.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeUtil.java index c533a9ccf..5eff62b7e 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeUtil.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/LaMetricTimeUtil.java @@ -15,9 +15,10 @@ package org.openhab.binding.lametrictime.internal; import java.util.HashMap; import java.util.Map; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Widget; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; import com.google.gson.JsonPrimitive; @@ -26,6 +27,7 @@ import com.google.gson.JsonPrimitive; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class LaMetricTimeUtil { private static final Map CORE_APP_LABELS = new HashMap<>(); static { diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/WidgetRef.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/WidgetRef.java index 26011f778..6836e0dc3 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/WidgetRef.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/WidgetRef.java @@ -12,11 +12,14 @@ */ package org.openhab.binding.lametrictime.internal; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * This bean represents the information necessary to uniquely reference a widget on the LaMetric Time platform. * * @author Gregor Moyer - Initial contribution */ +@NonNullByDefault public class WidgetRef { private final String packageName; private final String widgetId; diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/Configuration.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/Configuration.java new file mode 100644 index 000000000..8d1e4f94f --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/Configuration.java @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration; +import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration; + +/** + * Configuration class for LaMetric Time. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class Configuration { + @Nullable + private String deviceHost; + @Nullable + private String deviceApiKey; + + private boolean ignoreDeviceCertificateValidation = true; + private boolean ignoreDeviceHostnameValidation = true; + + private boolean logging = false; + private String logLevel = "INFO"; + private int logMax = 104857600; // 100kb + + public @Nullable String getDeviceHost() { + return deviceHost; + } + + public void setDeviceHost(String deviceHost) { + this.deviceHost = deviceHost; + } + + public Configuration withDeviceHost(@Nullable String deviceHost) { + this.deviceHost = deviceHost; + return this; + } + + public @Nullable String getDeviceApiKey() { + return deviceApiKey; + } + + public void setDeviceApiKey(String deviceApiKey) { + this.deviceApiKey = deviceApiKey; + } + + public Configuration withDeviceApiKey(@Nullable String deviceApiKey) { + this.deviceApiKey = deviceApiKey; + return this; + } + + public boolean isIgnoreDeviceCertificateValidation() { + return ignoreDeviceCertificateValidation; + } + + public void setIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) { + this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation; + } + + public Configuration withIgnoreDeviceCertificateValidation(boolean ignoreDeviceCertificateValidation) { + this.ignoreDeviceCertificateValidation = ignoreDeviceCertificateValidation; + return this; + } + + public boolean isIgnoreDeviceHostnameValidation() { + return ignoreDeviceHostnameValidation; + } + + public void setIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) { + this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation; + } + + public Configuration withIgnoreDeviceHostnameValidation(boolean ignoreDeviceHostnameValidation) { + this.ignoreDeviceHostnameValidation = ignoreDeviceHostnameValidation; + return this; + } + + public boolean isLogging() { + return logging; + } + + public void setLogging(boolean logging) { + this.logging = logging; + } + + public Configuration withLogging(boolean logging) { + this.logging = logging; + return this; + } + + public String getLogLevel() { + return logLevel; + } + + public void setLogLevel(String logLevel) { + this.logLevel = logLevel; + } + + public Configuration withLogLevel(String logLevel) { + this.logLevel = logLevel; + return this; + } + + public int getLogMax() { + return logMax; + } + + public void setLogMax(int logMax) { + this.logMax = logMax; + } + + public Configuration withLogMax(int logMax) { + this.logMax = logMax; + return this; + } + + public LocalConfiguration getLocalConfig() { + return new LocalConfiguration().withHost(deviceHost).withApiKey(deviceApiKey) + .withIgnoreCertificateValidation(ignoreDeviceCertificateValidation) + .withIgnoreHostnameValidation(ignoreDeviceHostnameValidation).withLogging(logging) + .withLogLevel(logLevel).withLogMax(logMax); + } + + public CloudConfiguration getCloudConfig() { + return new CloudConfiguration().withLogging(logging).withLogLevel(logLevel).withLogMax(logMax); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/LaMetricTime.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/LaMetricTime.java similarity index 80% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/LaMetricTime.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/LaMetricTime.java index d331f6e3a..86214b67a 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/LaMetricTime.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/LaMetricTime.java @@ -1,48 +1,52 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api; +package org.openhab.binding.lametrictime.internal.api; import javax.ws.rs.client.ClientBuilder; -import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration; -import org.openhab.binding.lametrictime.api.cloud.LaMetricTimeCloud; -import org.openhab.binding.lametrictime.api.impl.LaMetricTimeImpl; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; -import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException; -import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal; -import org.openhab.binding.lametrictime.api.local.LocalConfiguration; -import org.openhab.binding.lametrictime.api.local.NotificationCreationException; -import org.openhab.binding.lametrictime.api.local.UpdateException; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; -import org.openhab.binding.lametrictime.api.local.model.Widget; -import org.openhab.binding.lametrictime.api.model.CoreAction; -import org.openhab.binding.lametrictime.api.model.CoreApplication; -import org.openhab.binding.lametrictime.api.model.CoreApps; -import org.openhab.binding.lametrictime.api.model.Icon; -import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode; -import org.openhab.binding.lametrictime.api.model.enums.Priority; -import org.openhab.binding.lametrictime.api.model.enums.Sound; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration; +import org.openhab.binding.lametrictime.internal.api.cloud.LaMetricTimeCloud; +import org.openhab.binding.lametrictime.internal.api.dto.CoreAction; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApplication; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.dto.Icon; +import org.openhab.binding.lametrictime.internal.api.dto.enums.BrightnessMode; +import org.openhab.binding.lametrictime.internal.api.dto.enums.Priority; +import org.openhab.binding.lametrictime.internal.api.dto.enums.Sound; +import org.openhab.binding.lametrictime.internal.api.impl.LaMetricTimeImpl; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.LaMetricTimeLocal; +import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration; +import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException; +import org.openhab.binding.lametrictime.internal.api.local.UpdateException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; -public interface LaMetricTime -{ +/** + * Interface for LaMetric Time devices. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public interface LaMetricTime { /** * Get the version identifier reported by the device. * @@ -124,12 +128,8 @@ public interface LaMetricTime * @throws NotificationCreationException * if there is a communication error or malformed data */ - public String notify(String message, - Priority priority, - Icon icon, - Sound sound, - int messageRepeat, - int soundRepeat) throws NotificationCreationException; + public String notify(String message, Priority priority, Icon icon, Sound sound, int messageRepeat, int soundRepeat) + throws NotificationCreationException; /** * Get the built-in clock application. This applications displays the time @@ -137,7 +137,7 @@ public interface LaMetricTime * * @return the clock app */ - public Application getClock(); + public @Nullable Application getClock(); /** * Get the built-in countdown timer application. This application counts @@ -146,7 +146,7 @@ public interface LaMetricTime * * @return the countdown app */ - public Application getCountdown(); + public @Nullable Application getCountdown(); /** * Get the built-in radio application. The radio can play streams from the @@ -155,7 +155,7 @@ public interface LaMetricTime * * @return the radio app */ - public Application getRadio(); + public @Nullable Application getRadio(); /** * Get the built-in stopwatch application. The stopwatch counts time @@ -163,7 +163,7 @@ public interface LaMetricTime * * @return the stopwatch app */ - public Application getStopwatch(); + public @Nullable Application getStopwatch(); /** * Get the built-in weather application. This application displays the @@ -172,7 +172,7 @@ public interface LaMetricTime * * @return the weather app */ - public Application getWeather(); + public @Nullable Application getWeather(); /** * Get any of the built-in applications. @@ -181,7 +181,7 @@ public interface LaMetricTime * the app to retrieve * @return the requested app */ - public Application getApplication(CoreApplication coreApp); + public @Nullable Application getApplication(CoreApplication coreApp); /** * Get any application installed on the device. @@ -192,7 +192,7 @@ public interface LaMetricTime * @throws ApplicationNotFoundException * if the requested app is not found on the device */ - public Application getApplication(String name) throws ApplicationNotFoundException; + public @Nullable Application getApplication(@Nullable String name) throws ApplicationNotFoundException; /** * Display the given built-in application on the device. @@ -264,7 +264,7 @@ public interface LaMetricTime * @throws ApplicationActionException * if the action cannot be performed */ - public void doAction(Widget widget, CoreAction action) throws ApplicationActionException; + public void doAction(@Nullable Widget widget, CoreAction action) throws ApplicationActionException; /** * Perform the given action on the given widget. A widget is simply an @@ -388,8 +388,7 @@ public interface LaMetricTime * the configuration parameters that the new instance will use * @return the API instance */ - public static LaMetricTime create(Configuration config) - { + public static LaMetricTime create(Configuration config) { return new LaMetricTimeImpl(config); } @@ -405,8 +404,7 @@ public interface LaMetricTime * communicating with the device and cloud services * @return the API instance */ - public static LaMetricTime create(Configuration config, ClientBuilder clientBuilder) - { + public static LaMetricTime create(Configuration config, ClientBuilder clientBuilder) { return new LaMetricTimeImpl(config, clientBuilder); } @@ -421,9 +419,7 @@ public interface LaMetricTime * the cloud API configuration for the new instance * @return the API instance */ - public static LaMetricTime create(LocalConfiguration localConfig, - CloudConfiguration cloudConfig) - { + public static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig) { return new LaMetricTimeImpl(localConfig, cloudConfig); } @@ -440,10 +436,8 @@ public interface LaMetricTime * communicating with the device and cloud services * @return the API instance */ - public static LaMetricTime create(LocalConfiguration localConfig, - CloudConfiguration cloudConfig, - ClientBuilder clientBuilder) - { + public static LaMetricTime create(LocalConfiguration localConfig, CloudConfiguration cloudConfig, + ClientBuilder clientBuilder) { return new LaMetricTimeImpl(localConfig, cloudConfig, clientBuilder); } } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/CloudConfiguration.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/CloudConfiguration.java new file mode 100644 index 000000000..fb62ae4b5 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/CloudConfiguration.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud; + +import java.net.URI; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Cloud configuration class for LaMetric Time. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class CloudConfiguration { + private URI baseUri = URI.create("https://developer.lametric.com/api/v2"); + + private boolean logging = false; + private String logLevel = "INFO"; + private int logMax = 104857600; // 100kb + + public URI getBaseUri() { + return baseUri; + } + + public void setBaseUri(URI baseUri) { + this.baseUri = baseUri; + } + + public CloudConfiguration withBaseUri(URI baseUri) { + this.baseUri = baseUri; + return this; + } + + public boolean isLogging() { + return logging; + } + + public void setLogging(boolean logging) { + this.logging = logging; + } + + public CloudConfiguration withLogging(boolean logging) { + this.logging = logging; + return this; + } + + public String getLogLevel() { + return logLevel; + } + + public void setLogLevel(String logLevel) { + this.logLevel = logLevel; + } + + public CloudConfiguration withLogLevel(String logLevel) { + this.logLevel = logLevel; + return this; + } + + public int getLogMax() { + return logMax; + } + + public void setLogMax(int logMax) { + this.logMax = logMax; + } + + public CloudConfiguration withLogMax(int logMax) { + this.logMax = logMax; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/LaMetricTimeCloud.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/LaMetricTimeCloud.java new file mode 100644 index 000000000..7a948a9a6 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/LaMetricTimeCloud.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud; + +import javax.ws.rs.client.ClientBuilder; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.cloud.dto.IconFilter; +import org.openhab.binding.lametrictime.internal.api.cloud.dto.Icons; +import org.openhab.binding.lametrictime.internal.api.cloud.impl.LaMetricTimeCloudImpl; + +/** + * Interface for LaMetric Time cloud. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public interface LaMetricTimeCloud { + public Icons getIcons(); + + public Icons getIcons(IconFilter filter); + + public static LaMetricTimeCloud create(CloudConfiguration config) { + return new LaMetricTimeCloudImpl(config); + } + + public static LaMetricTimeCloud create(CloudConfiguration config, ClientBuilder clientBuilder) { + return new LaMetricTimeCloudImpl(config, clientBuilder); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icon.java new file mode 100644 index 000000000..5efa3aa4f --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icon.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +/** + * Pojo for icon. + * + * @author Gregory Moyer - Initial contribution + */ +public class Icon { + private Integer id; + private String title; + private String code; + private IconType type; + private String category; + private String url; + private Thumb thumb; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Icon withId(Integer id) { + this.id = id; + return this; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Icon withTitle(String title) { + this.title = title; + return this; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public Icon withCode(String code) { + this.code = code; + return this; + } + + public IconType getType() { + return type; + } + + public void setType(IconType type) { + this.type = type; + } + + public Icon withType(IconType type) { + this.type = type; + return this; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Icon withCategory(String category) { + this.category = category; + return this; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public Icon withUrl(String url) { + this.url = url; + return this; + } + + public Thumb getThumb() { + return thumb; + } + + public void setThumb(Thumb thumb) { + this.thumb = thumb; + } + + public Icon withThumb(Thumb thumb) { + this.thumb = thumb; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconField.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconField.java new file mode 100644 index 000000000..bfc31ba09 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconField.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +import com.google.gson.annotations.SerializedName; + +/** + * Pojo for icon field. + * + * @author Gregory Moyer - Initial contribution + */ +public enum IconField { + @SerializedName("id") + ID, + @SerializedName("title") + TITLE, + @SerializedName("code") + CODE, + @SerializedName("type") + TYPE, + @SerializedName("url") + URL, + @SerializedName("thumb") + THUMB +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconFilter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconFilter.java new file mode 100644 index 000000000..21b0f1480 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconFilter.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +import java.util.List; + +/** + * Pojo for icon filter. + * + * @author Gregory Moyer - Initial contribution + */ +public class IconFilter { + private Integer page; + private Integer pageSize; + private List fields; + private IconOrder order; + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public IconFilter withPage(Integer page) { + this.page = page; + return this; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public IconFilter withPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public List getFields() { + return fields; + } + + public String getFieldsString() { + if (fields == null || fields.isEmpty()) { + return null; + } + + StringBuilder builder = new StringBuilder(); + builder.append(fields.get(0).name().toLowerCase()); + + for (int i = 1; i < fields.size(); i++) { + builder.append(',').append(fields.get(i).name().toLowerCase()); + } + + return builder.toString(); + } + + public void setFields(List fields) { + this.fields = fields; + } + + public IconFilter withFields(List fields) { + this.fields = fields; + return this; + } + + public IconOrder getOrder() { + return order; + } + + public String getOrderString() { + return order == null ? null : order.name().toLowerCase(); + } + + public void setOrder(IconOrder order) { + this.order = order; + } + + public IconFilter withOrder(IconOrder order) { + this.order = order; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconOrder.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconOrder.java new file mode 100644 index 000000000..e745dd051 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconOrder.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +import com.google.gson.annotations.SerializedName; + +/** + * Enum for icon order. + * + * @author Gregory Moyer - Initial contribution + */ +public enum IconOrder { + @SerializedName("popular") + POPULAR, + @SerializedName("newest") + NEWEST, + @SerializedName("title") + TITLE +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconType.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconType.java new file mode 100644 index 000000000..ee388a90a --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconType.java @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +import com.google.gson.annotations.SerializedName; + +/** + * Enum for icon type. + * + * @author Gregory Moyer - Initial contribution + */ +public enum IconType { + @SerializedName("picture") + PICTURE, + @SerializedName("movie") + MOVIE +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icons.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icons.java new file mode 100644 index 000000000..d269f5690 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Icons.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +import java.util.ArrayList; +import java.util.List; + +/** + * Pojo for icons. + * + * @author Gregory Moyer - Initial contribution + */ +public class Icons { + private IconsMetadata meta; + private List data = new ArrayList(); + + public IconsMetadata getMeta() { + return meta; + } + + public void setMeta(IconsMetadata meta) { + this.meta = meta; + } + + public Icons withMeta(IconsMetadata meta) { + this.meta = meta; + return this; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public Icons withData(List data) { + this.data = data; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconsMetadata.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconsMetadata.java new file mode 100644 index 000000000..5e0d6c4f5 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/IconsMetadata.java @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +/** + * Pojo for icons metadata. + * + * @author Gregory Moyer - Initial contribution + */ +public class IconsMetadata { + private Integer totalIconCount; + private Integer page; + private Integer pageSize; + private Integer pageCount; + + public Integer getTotalIconCount() { + return totalIconCount; + } + + public void setTotalIconCount(Integer totalIconCount) { + this.totalIconCount = totalIconCount; + } + + public IconsMetadata withTotalIconCount(Integer totalIconCount) { + this.totalIconCount = totalIconCount; + return this; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public IconsMetadata withPage(Integer page) { + this.page = page; + return this; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public IconsMetadata withPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public Integer getPageCount() { + return pageCount; + } + + public void setPageCount(Integer pageCount) { + this.pageCount = pageCount; + } + + public IconsMetadata withPageCount(Integer pageCount) { + this.pageCount = pageCount; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Thumb.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Thumb.java new file mode 100644 index 000000000..9c87f5c29 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/dto/Thumb.java @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.cloud.dto; + +/** + * Pojo for thumb. + * + * @author Gregory Moyer - Initial contribution + */ +public class Thumb { + private String original; + private String small; + private String large; + private String xlarge; + + public String getOriginal() { + return original; + } + + public void setOriginal(String original) { + this.original = original; + } + + public Thumb withOriginal(String original) { + this.original = original; + return this; + } + + public String getSmall() { + return small; + } + + public void setSmall(String small) { + this.small = small; + } + + public Thumb withSmall(String small) { + this.small = small; + return this; + } + + public String getLarge() { + return large; + } + + public void setLarge(String large) { + this.large = large; + } + + public Thumb withLarge(String large) { + this.large = large; + return this; + } + + public String getXlarge() { + return xlarge; + } + + public void setXlarge(String xlarge) { + this.xlarge = xlarge; + } + + public Thumb withXlarge(String xlarge) { + this.xlarge = xlarge; + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/impl/LaMetricTimeCloudImpl.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/impl/LaMetricTimeCloudImpl.java similarity index 59% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/impl/LaMetricTimeCloudImpl.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/impl/LaMetricTimeCloudImpl.java index 11cdf9710..bb48c5cfd 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/cloud/impl/LaMetricTimeCloudImpl.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/cloud/impl/LaMetricTimeCloudImpl.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.cloud.impl; +package org.openhab.binding.lametrictime.internal.api.cloud.impl; import java.util.logging.Logger; @@ -21,14 +18,22 @@ import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; import javax.ws.rs.core.MediaType; -import org.openhab.binding.lametrictime.api.cloud.CloudConfiguration; -import org.openhab.binding.lametrictime.api.cloud.LaMetricTimeCloud; -import org.openhab.binding.lametrictime.api.cloud.model.IconFilter; -import org.openhab.binding.lametrictime.api.cloud.model.Icons; -import org.openhab.binding.lametrictime.api.common.impl.AbstractClient; -import org.openhab.binding.lametrictime.api.filter.LoggingFilter; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lametrictime.internal.GsonProvider; +import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration; +import org.openhab.binding.lametrictime.internal.api.cloud.LaMetricTimeCloud; +import org.openhab.binding.lametrictime.internal.api.cloud.dto.IconFilter; +import org.openhab.binding.lametrictime.internal.api.cloud.dto.Icons; +import org.openhab.binding.lametrictime.internal.api.common.impl.AbstractClient; +import org.openhab.binding.lametrictime.internal.api.filter.LoggingFilter; +/** + * Implementation class for LaMetricTimeCloud interface. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault public class LaMetricTimeCloudImpl extends AbstractClient implements LaMetricTimeCloud { private final CloudConfiguration config; @@ -48,7 +53,7 @@ public class LaMetricTimeCloudImpl extends AbstractClient implements LaMetricTim } @Override - public Icons getIcons(IconFilter filter) { + public Icons getIcons(@Nullable IconFilter filter) { return getClient().target(config.getBaseUri()).path("/icons").queryParam("page", filter.getPage()) .queryParam("page_size", filter.getPageSize()).queryParam("fields", filter.getFieldsString()) .queryParam("order", filter.getOrderString()).request(MediaType.APPLICATION_JSON_TYPE).get(Icons.class); diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/AbstractClient.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/AbstractClient.java similarity index 59% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/AbstractClient.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/AbstractClient.java index 84ec64a23..0e5bfa866 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/AbstractClient.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/AbstractClient.java @@ -1,29 +1,37 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.common.impl; +package org.openhab.binding.lametrictime.internal.api.common.impl; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + import com.google.gson.Gson; +/** + * Abstract class for clients. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault public abstract class AbstractClient { protected final ClientBuilder clientBuilder; + @Nullable private volatile Client client; + @Nullable private volatile Gson gson; public AbstractClient() { @@ -34,7 +42,7 @@ public abstract class AbstractClient { this.clientBuilder = clientBuilder; } - protected Client getClient() { + protected @Nullable Client getClient() { if (client == null) { synchronized (this) { if (client == null) { @@ -46,7 +54,7 @@ public abstract class AbstractClient { return client; } - protected Gson getGson() { + protected @Nullable Gson getGson() { if (gson == null) { synchronized (this) { if (gson == null) { diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/GsonGenerator.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/GsonGenerator.java new file mode 100644 index 000000000..2d5b74d84 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/GsonGenerator.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.common.impl; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.ActionTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.ApplicationTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.UpdateActionTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported.JSR310TypeAdapters; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported.RuntimeTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.local.dto.BooleanParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.IntegerParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.Parameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.StringParameter; + +import com.google.gson.FieldNamingPolicy; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * Class for json generation support. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class GsonGenerator { + public static Gson create() { + return create(false); + } + + public static Gson create(boolean prettyPrint) { + GsonBuilder builder = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) + .registerTypeAdapterFactory(new ApplicationTypeAdapterFactory()) + .registerTypeAdapterFactory(new ActionTypeAdapterFactory()) + .registerTypeAdapterFactory(new UpdateActionTypeAdapterFactory()) + .registerTypeAdapterFactory(RuntimeTypeAdapterFactory.of(Parameter.class, "data_type") + .registerSubtype(BooleanParameter.class, "bool") + .registerSubtype(StringParameter.class, "string") + .registerSubtype(IntegerParameter.class, "int")); + + // add Java 8 Time API support + JSR310TypeAdapters.registerJSR310TypeAdapters(builder); + + if (prettyPrint) { + builder.setPrettyPrinting(); + } + + return builder.create(); + } + + // @formatter:off + private GsonGenerator() {} + // @formatter:on +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ActionTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ActionTypeAdapterFactory.java similarity index 51% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ActionTypeAdapterFactory.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ActionTypeAdapterFactory.java index e519e8608..d8eae7cd4 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ActionTypeAdapterFactory.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ActionTypeAdapterFactory.java @@ -1,87 +1,80 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters; +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.local.model.Action; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.local.dto.Action; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -public class ActionTypeAdapterFactory extends CustomizedTypeAdapterFactory -{ +/** + * Adapter factory for actions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class ActionTypeAdapterFactory extends CustomizedTypeAdapterFactory { private static final String PROPERTY_ID = "id"; private static final String PROPERTY_PARAMETERS = "params"; - public ActionTypeAdapterFactory() - { + public ActionTypeAdapterFactory() { super(Action.class); } @Override - protected void beforeWrite(Action source, JsonElement toSerialize) - { - if (toSerialize == null || toSerialize.isJsonNull()) - { + protected void beforeWrite(Action source, JsonElement toSerialize) { + if (toSerialize == null || toSerialize.isJsonNull()) { return; } JsonObject actionObj = toSerialize.getAsJsonObject(); - if (actionObj == null || actionObj.isJsonNull()) - { + if (actionObj == null || actionObj.isJsonNull()) { return; } // rewrite parameters from a nested object (map) to properties on the action JsonElement paramsElem = actionObj.get(PROPERTY_PARAMETERS); - if (paramsElem != null && !paramsElem.isJsonNull()) - { + if (paramsElem != null && !paramsElem.isJsonNull()) { JsonObject paramsObj = paramsElem.getAsJsonObject(); actionObj.remove(PROPERTY_PARAMETERS); - for (Entry entry : paramsObj.entrySet()) - { + for (Entry entry : paramsObj.entrySet()) { actionObj.add(entry.getKey(), entry.getValue()); } } } @Override - protected void afterRead(JsonElement deserialized) - { - if (deserialized == null || deserialized.isJsonNull()) - { + protected void afterRead(@Nullable JsonElement deserialized) { + if (deserialized == null || deserialized.isJsonNull()) { return; } JsonObject actionObj = deserialized.getAsJsonObject(); - if (actionObj == null || actionObj.isJsonNull()) - { + if (actionObj == null || actionObj.isJsonNull()) { return; } - if (actionObj.has(PROPERTY_PARAMETERS)) - { - throw new IllegalArgumentException("Attempting to deserialize Action that contains a colliding " - + PROPERTY_PARAMETERS - + " property"); + if (actionObj.has(PROPERTY_PARAMETERS)) { + throw new IllegalArgumentException( + "Attempting to deserialize Action that contains a colliding " + PROPERTY_PARAMETERS + " property"); } // temporary list of field names @@ -89,11 +82,9 @@ public class ActionTypeAdapterFactory extends CustomizedTypeAdapterFactory entry : actionObj.entrySet()) - { + for (Entry entry : actionObj.entrySet()) { // skip ID field - if (PROPERTY_ID.equals(entry.getKey())) - { + if (PROPERTY_ID.equals(entry.getKey())) { continue; } diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java similarity index 57% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java index fed128159..caa6296f3 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/ApplicationTypeAdapterFactory.java @@ -1,62 +1,59 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters; +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters; import java.util.Map.Entry; -import org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; -import org.openhab.binding.lametrictime.api.local.model.Application; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -public class ApplicationTypeAdapterFactory extends CustomizedTypeAdapterFactory -{ +/** + * Adapter factory for applications. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class ApplicationTypeAdapterFactory extends CustomizedTypeAdapterFactory { private static final String PROPERTY_ID = "id"; private static final String PROPERTY_WIDGETS = "widgets"; private static final String PROPERTY_ACTIONS = "actions"; - public ApplicationTypeAdapterFactory() - { + public ApplicationTypeAdapterFactory() { super(Application.class); } @Override - protected void beforeWrite(Application source, JsonElement toSerialize) - { - if (toSerialize == null || toSerialize.isJsonNull()) - { + protected void beforeWrite(Application source, JsonElement toSerialize) { + if (toSerialize == null || toSerialize.isJsonNull()) { return; } JsonObject appObj = toSerialize.getAsJsonObject(); - if (appObj == null || appObj.isJsonNull()) - { + if (appObj == null || appObj.isJsonNull()) { return; } // remove widget IDs JsonElement widgetsElem = appObj.get(PROPERTY_WIDGETS); - if (widgetsElem != null && !widgetsElem.isJsonNull()) - { - for (Entry entry : widgetsElem.getAsJsonObject().entrySet()) - { + if (widgetsElem != null && !widgetsElem.isJsonNull()) { + for (Entry entry : widgetsElem.getAsJsonObject().entrySet()) { JsonElement widgetElem = entry.getValue(); - if (widgetElem == null || widgetElem.isJsonNull()) - { + if (widgetElem == null || widgetElem.isJsonNull()) { continue; } widgetElem.getAsJsonObject().remove(PROPERTY_ID); @@ -65,13 +62,10 @@ public class ApplicationTypeAdapterFactory extends CustomizedTypeAdapterFactory< // remove action IDs JsonElement actionsElem = appObj.get(PROPERTY_ACTIONS); - if (actionsElem != null && !actionsElem.isJsonNull()) - { - for (Entry entry : actionsElem.getAsJsonObject().entrySet()) - { + if (actionsElem != null && !actionsElem.isJsonNull()) { + for (Entry entry : actionsElem.getAsJsonObject().entrySet()) { JsonElement actionElem = entry.getValue(); - if (actionElem == null || actionElem.isJsonNull()) - { + if (actionElem == null || actionElem.isJsonNull()) { continue; } actionElem.getAsJsonObject().remove(PROPERTY_ID); @@ -80,28 +74,22 @@ public class ApplicationTypeAdapterFactory extends CustomizedTypeAdapterFactory< } @Override - protected void afterRead(JsonElement deserialized) - { - if (deserialized == null || deserialized.isJsonNull()) - { + protected void afterRead(@Nullable JsonElement deserialized) { + if (deserialized == null || deserialized.isJsonNull()) { return; } JsonObject appObj = deserialized.getAsJsonObject(); - if (appObj == null || appObj.isJsonNull()) - { + if (appObj == null || appObj.isJsonNull()) { return; } // inject widget IDs JsonElement widgetsElem = appObj.get(PROPERTY_WIDGETS); - if (widgetsElem != null && !widgetsElem.isJsonNull()) - { - for (Entry entry : widgetsElem.getAsJsonObject().entrySet()) - { + if (widgetsElem != null && !widgetsElem.isJsonNull()) { + for (Entry entry : widgetsElem.getAsJsonObject().entrySet()) { JsonElement widgetElem = entry.getValue(); - if (widgetElem == null || widgetElem.isJsonNull()) - { + if (widgetElem == null || widgetElem.isJsonNull()) { continue; } widgetElem.getAsJsonObject().addProperty(PROPERTY_ID, entry.getKey()); @@ -110,13 +98,10 @@ public class ApplicationTypeAdapterFactory extends CustomizedTypeAdapterFactory< // inject action IDs JsonElement actionsElem = appObj.get(PROPERTY_ACTIONS); - if (actionsElem != null && !actionsElem.isJsonNull()) - { - for (Entry entry : actionsElem.getAsJsonObject().entrySet()) - { + if (actionsElem != null && !actionsElem.isJsonNull()) { + for (Entry entry : actionsElem.getAsJsonObject().entrySet()) { JsonElement actionElem = entry.getValue(); - if (actionElem == null || actionElem.isJsonNull()) - { + if (actionElem == null || actionElem.isJsonNull()) { continue; } actionElem.getAsJsonObject().addProperty(PROPERTY_ID, entry.getKey()); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java new file mode 100644 index 000000000..b6bd525fc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/UpdateActionTypeAdapterFactory.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters; + +import java.util.Map.Entry; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported.CustomizedTypeAdapterFactory; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; + +/** + * Adapter factory for update actions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class UpdateActionTypeAdapterFactory extends CustomizedTypeAdapterFactory { + private static final String PROPERTY_PARAMETERS = "params"; + private static final String PROPERTY_VALUE = "value"; + + public UpdateActionTypeAdapterFactory() { + super(UpdateAction.class); + } + + @Override + protected void beforeWrite(UpdateAction source, JsonElement toSerialize) { + if (toSerialize == null || toSerialize.isJsonNull()) { + return; + } + + JsonObject actionObj = toSerialize.getAsJsonObject(); + if (actionObj == null || actionObj.isJsonNull()) { + return; + } + + // rewrite parameters map from {name => Parameter} to {name => value} + JsonElement paramsElem = actionObj.get(PROPERTY_PARAMETERS); + if (paramsElem != null && !paramsElem.isJsonNull()) { + JsonObject paramsObj = paramsElem.getAsJsonObject(); + actionObj.remove(PROPERTY_PARAMETERS); + + JsonObject newParamsObj = new JsonObject(); + for (Entry entry : paramsObj.entrySet()) { + newParamsObj.add(entry.getKey(), entry.getValue().getAsJsonObject().getAsJsonPrimitive(PROPERTY_VALUE)); + } + actionObj.add(PROPERTY_PARAMETERS, newParamsObj); + } + } + + @Override + protected void afterRead(@Nullable JsonElement deserialized) { + throw new UnsupportedOperationException(UpdateAction.class.getName() + " cannot be derialized"); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java similarity index 72% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java index 3508d2ad5..bc7946a5b 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/CustomizedTypeAdapterFactory.java @@ -14,10 +14,12 @@ * Pulled from Stack Overflow answer located here: http://stackoverflow.com/a/11272452 * and placed in an appropriate package within this library. */ -package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported; +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; import java.io.IOException; -import java.io.ObjectStreamException; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -27,41 +29,41 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -public abstract class CustomizedTypeAdapterFactory implements TypeAdapterFactory -{ +/** + * Abstract type adapter factory. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public abstract class CustomizedTypeAdapterFactory implements TypeAdapterFactory { private final Class customizedClass; - public CustomizedTypeAdapterFactory(Class customizedClass) - { + public CustomizedTypeAdapterFactory(Class customizedClass) { this.customizedClass = customizedClass; } @Override @SuppressWarnings("unchecked") // we use a runtime check to guarantee that 'C' and 'T' are equal - public final TypeAdapter create(Gson gson, TypeToken type) - { + @Nullable + public final TypeAdapter create(@Nullable Gson gson, @Nullable TypeToken type) { return type.getRawType() == customizedClass - ? (TypeAdapter)customizeMyClassAdapter(gson, (TypeToken)type) + ? (TypeAdapter) customizeMyClassAdapter(gson, (TypeToken) type) : null; } - private TypeAdapter customizeMyClassAdapter(Gson gson, TypeToken type) - { + private TypeAdapter customizeMyClassAdapter(@Nullable Gson gson, TypeToken type) { final TypeAdapter delegate = gson.getDelegateAdapter(this, type); final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - return new TypeAdapter() - { + return new TypeAdapter() { @Override - public void write(JsonWriter out, C value) throws IOException - { + public void write(JsonWriter out, @Nullable C value) throws IOException { JsonElement tree = delegate.toJsonTree(value); beforeWrite(value, tree); elementAdapter.write(out, tree); } @Override - public C read(JsonReader in) throws IOException - { + public @Nullable C read(JsonReader in) throws IOException { JsonElement tree = elementAdapter.read(in); afterRead(tree); if (tree == null) { @@ -76,15 +78,13 @@ public abstract class CustomizedTypeAdapterFactory implements TypeAdapterFact * Override this to muck with {@code toSerialize} before it is written to * the outgoing JSON stream. */ - protected void beforeWrite(C source, JsonElement toSerialize) - { + protected void beforeWrite(C source, JsonElement toSerialize) { } /** * Override this to muck with {@code deserialized} before it parsed into the * application type. */ - protected void afterRead(JsonElement deserialized) - { + protected void afterRead(@Nullable JsonElement deserialized) { } } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java new file mode 100644 index 000000000..482056db9 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DateTimeTypeAdapter.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.util.function.Function; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +/** + * Abstract type adapter for jsr310 date-time types. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +abstract class DateTimeTypeAdapter extends TemporalTypeAdapter { + + DateTimeTypeAdapter(Function parseFunction) { + super(parseFunction); + } + + @Override + public String preProcess(@Nullable String in) { + if (in.endsWith("+0000")) { + return in.substring(0, in.length() - 5) + "Z"; + } + return in; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DurationTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DurationTypeAdapter.java new file mode 100644 index 000000000..1f27d40b0 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/DurationTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.Duration; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link Duration} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class DurationTypeAdapter extends TemporalTypeAdapter { + + public DurationTypeAdapter() { + super(Duration::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/InstantTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/InstantTypeAdapter.java new file mode 100644 index 000000000..9e337f2e2 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/InstantTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.Instant; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link Instant} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class InstantTypeAdapter extends DateTimeTypeAdapter { + + public InstantTypeAdapter() { + super(Instant::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java new file mode 100644 index 000000000..bb2ab97fd --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/JSR310TypeAdapters.java @@ -0,0 +1,117 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.MonthDay; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.Year; +import java.time.YearMonth; +import java.time.ZonedDateTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +import com.google.gson.GsonBuilder; + +/** + * Helper methods to register JSR310 type adapters. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class JSR310TypeAdapters { + + private JSR310TypeAdapters() { + } + + public static GsonBuilder registerDurationTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(Duration.class, new DurationTypeAdapter()); + } + + public static GsonBuilder registerInstantTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(Instant.class, new InstantTypeAdapter()); + } + + public static GsonBuilder registerLocalDateTimeTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeTypeAdapter()); + } + + public static GsonBuilder registerLocalDateTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(LocalDate.class, new LocalDateTypeAdapter()); + } + + public static GsonBuilder registerLocalTimeTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(LocalTime.class, new LocalTimeTypeAdapter()); + } + + public static GsonBuilder registerMonthDayTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(MonthDay.class, new MonthDayTypeAdapter()); + } + + public static GsonBuilder registerOffsetDateTimeTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(OffsetDateTime.class, new OffsetDateTimeTypeAdapter()); + } + + public static GsonBuilder registerOffsetTimeTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(OffsetTime.class, new OffsetTimeTypeAdapter()); + } + + public static GsonBuilder registerPeriodTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(Period.class, new PeriodTypeAdapter()); + } + + public static GsonBuilder registerYearMonthTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(YearMonth.class, new YearMonthTypeAdapter()); + } + + public static GsonBuilder registerYearTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(Year.class, new YearTypeAdapter()); + } + + public static GsonBuilder registerZonedDateTimeTypeAdapter(GsonBuilder gsonBuilder) { + return gsonBuilder.registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeTypeAdapter()); + } + + /** + * Helper method to register all the available JSR310 adapters at once. + * + * @param gsonBuilder the gsonBuilder on which all the JSR310 adapters must be registered. + * @return the gsonBuilder with the JSR310 adapters registered. + */ + public static GsonBuilder registerJSR310TypeAdapters(GsonBuilder gsonBuilder) { + registerDurationTypeAdapter(gsonBuilder); + registerInstantTypeAdapter(gsonBuilder); + registerLocalDateTimeTypeAdapter(gsonBuilder); + registerLocalDateTypeAdapter(gsonBuilder); + registerLocalTimeTypeAdapter(gsonBuilder); + registerMonthDayTypeAdapter(gsonBuilder); + registerOffsetDateTimeTypeAdapter(gsonBuilder); + registerOffsetTimeTypeAdapter(gsonBuilder); + registerPeriodTypeAdapter(gsonBuilder); + registerYearMonthTypeAdapter(gsonBuilder); + registerYearTypeAdapter(gsonBuilder); + registerZonedDateTimeTypeAdapter(gsonBuilder); + + return gsonBuilder; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java new file mode 100644 index 000000000..332561b47 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTimeTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.LocalDateTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link LocalDateTime} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class LocalDateTimeTypeAdapter extends DateTimeTypeAdapter { + + public LocalDateTimeTypeAdapter() { + super(LocalDateTime::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java new file mode 100644 index 000000000..f8fee7e5a --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalDateTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.LocalDate; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link LocalDate} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class LocalDateTypeAdapter extends TemporalTypeAdapter { + + public LocalDateTypeAdapter() { + super(LocalDate::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java new file mode 100644 index 000000000..552d67fc3 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/LocalTimeTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.LocalTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link LocalTime} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class LocalTimeTypeAdapter extends TemporalTypeAdapter { + + public LocalTimeTypeAdapter() { + super(LocalTime::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java new file mode 100644 index 000000000..1a6b87db0 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/MonthDayTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.MonthDay; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link MonthDay} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class MonthDayTypeAdapter extends TemporalTypeAdapter { + + public MonthDayTypeAdapter() { + super(MonthDay::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java new file mode 100644 index 000000000..d1e6ed7dc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetDateTimeTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.OffsetDateTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link OffsetDateTime} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter { + + public OffsetDateTimeTypeAdapter() { + super(OffsetDateTime::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java new file mode 100644 index 000000000..703d63df0 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/OffsetTimeTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.OffsetTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link OffsetTime} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class OffsetTimeTypeAdapter extends TemporalTypeAdapter { + + public OffsetTimeTypeAdapter() { + super(OffsetTime::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java new file mode 100644 index 000000000..67b35dc48 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/PeriodTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.Period; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link Period} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class PeriodTypeAdapter extends TemporalTypeAdapter { + + public PeriodTypeAdapter() { + super(Period::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java new file mode 100644 index 000000000..e91895378 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/RuntimeTypeAdapterFactory.java @@ -0,0 +1,455 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Copied from + * https://raw.githubusercontent.com/google/gson/master/extras/src/main/java/com/google/gson/typeadapters/RuntimeTypeAdapterFactory.java + * and repackaged here with additional content from + * com.google.gson.internal.{Streams,TypeAdapters,LazilyParsedNumber} + * to avoid using the internal package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.io.EOFException; +import java.io.IOException; +import java.io.ObjectStreamException; +import java.math.BigDecimal; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonIOException; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonPrimitive; +import com.google.gson.JsonSyntaxException; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.stream.MalformedJsonException; + +/** + * Adapts values whose runtime type may differ from their declaration type. This + * is necessary when a field's type is not the same type that GSON should create + * when deserializing that field. For example, consider these types: + * + *
+ * {
+ *     @code
+ *     abstract class Shape {
+ *         int x;
+ *         int y;
+ *     }
+ *     class Circle extends Shape {
+ *         int radius;
+ *     }
+ *     class Rectangle extends Shape {
+ *         int width;
+ *         int height;
+ *     }
+ *     class Diamond extends Shape {
+ *         int width;
+ *         int height;
+ *     }
+ *     class Drawing {
+ *         Shape bottomShape;
+ *         Shape topShape;
+ *     }
+ * }
+ * 
+ *

+ * Without additional type information, the serialized JSON is ambiguous. Is + * the bottom shape in this drawing a rectangle or a diamond? + * + *

+ *    {@code
+ *   {
+ *     "bottomShape": {
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * 
+ * + * This class addresses this problem by adding type information to the + * serialized JSON and honoring that type information when the JSON is + * deserialized: + * + *
+ *    {@code
+ *   {
+ *     "bottomShape": {
+ *       "type": "Diamond",
+ *       "width": 10,
+ *       "height": 5,
+ *       "x": 0,
+ *       "y": 0
+ *     },
+ *     "topShape": {
+ *       "type": "Circle",
+ *       "radius": 2,
+ *       "x": 4,
+ *       "y": 1
+ *     }
+ *   }}
+ * 
+ * + * Both the type field name ({@code "type"}) and the type labels ({@code + * "Rectangle"}) are configurable. + * + *

Registering Types

+ * Create a {@code RuntimeTypeAdapterFactory} by passing the base type and type field + * name to the {@link #of} factory method. If you don't supply an explicit type + * field name, {@code "type"} will be used. + * + *
+ * {
+ *     @code
+ *     RuntimeTypeAdapterFactory shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class, "type");
+ * }
+ * 
+ * + * Next register all of your subtypes. Every subtype must be explicitly + * registered. This protects your application from injection attacks. If you + * don't supply an explicit type label, the type's simple name will be used. + * + *
+ *    {@code
+ *   shapeAdapter.registerSubtype(Rectangle.class, "Rectangle");
+ *   shapeAdapter.registerSubtype(Circle.class, "Circle");
+ *   shapeAdapter.registerSubtype(Diamond.class, "Diamond");
+ * }
+ * 
+ * + * Finally, register the type adapter factory in your application's GSON builder: + * + *
+ * {
+ *     @code
+ *     Gson gson = new GsonBuilder().registerTypeAdapterFactory(shapeAdapterFactory).create();
+ * }
+ * 
+ * + * Like {@code GsonBuilder}, this API supports chaining: + * + *
+ * {
+ *     @code
+ *     RuntimeTypeAdapterFactory shapeAdapterFactory = RuntimeTypeAdapterFactory.of(Shape.class)
+ *             .registerSubtype(Rectangle.class).registerSubtype(Circle.class).registerSubtype(Diamond.class);
+ * }
+ * 
+ * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public final class RuntimeTypeAdapterFactory implements TypeAdapterFactory { + private final Class baseType; + private final String typeFieldName; + private final Map> labelToSubtype = new LinkedHashMap>(); + private final Map, String> subtypeToLabel = new LinkedHashMap, String>(); + + private RuntimeTypeAdapterFactory(Class baseType, String typeFieldName) { + if (typeFieldName == null || baseType == null) { + throw new IllegalArgumentException(); + } + this.baseType = baseType; + this.typeFieldName = typeFieldName; + } + + /** + * Creates a new runtime type adapter using for {@code baseType} using {@code + * typeFieldName} as the type field name. Type field names are case sensitive. + */ + public static RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { + return new RuntimeTypeAdapterFactory(baseType, typeFieldName); + } + + /** + * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as + * the type field name. + */ + public static RuntimeTypeAdapterFactory of(Class baseType) { + return new RuntimeTypeAdapterFactory(baseType, "type"); + } + + /** + * Registers {@code type} identified by {@code label}. Labels are case + * sensitive. + * + * @throws IllegalArgumentException if either {@code type} or {@code label} + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type, String label) { + if (type == null || label == null) { + throw new IllegalArgumentException(); + } + if (subtypeToLabel.containsKey(type) || labelToSubtype.containsKey(label)) { + throw new IllegalArgumentException("types and labels must be unique"); + } + labelToSubtype.put(label, type); + subtypeToLabel.put(type, label); + return this; + } + + /** + * Registers {@code type} identified by its {@link Class#getSimpleName simple + * name}. Labels are case sensitive. + * + * @throws IllegalArgumentException if either {@code type} or its simple name + * have already been registered on this type adapter. + */ + public RuntimeTypeAdapterFactory registerSubtype(Class type) { + return registerSubtype(type, type.getSimpleName()); + } + + @Override + public @Nullable TypeAdapter create(@Nullable Gson gson, @Nullable TypeToken type) { + if (type.getRawType() != baseType) { + return null; + } + + final Map> labelToDelegate = new LinkedHashMap>(); + final Map, TypeAdapter> subtypeToDelegate = new LinkedHashMap, TypeAdapter>(); + for (Map.Entry> entry : labelToSubtype.entrySet()) { + TypeAdapter delegate = gson.getDelegateAdapter(this, TypeToken.get(entry.getValue())); + labelToDelegate.put(entry.getKey(), delegate); + subtypeToDelegate.put(entry.getValue(), delegate); + } + + return new TypeAdapter() { + @Override + public @Nullable R read(JsonReader in) throws IOException { + JsonElement jsonElement = RuntimeTypeAdapterFactory.parse(in); + JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); + if (labelJsonElement == null) { + throw new JsonParseException("cannot deserialize " + baseType + + " because it does not define a field named " + typeFieldName); + } + String label = labelJsonElement.getAsString(); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) labelToDelegate.get(label); + if (delegate == null) { + throw new JsonParseException("cannot deserialize " + baseType + " subtype named " + label + + "; did you forget to register a subtype?"); + } + return delegate.fromJsonTree(jsonElement); + } + + @Override + public void write(JsonWriter out, @Nullable R value) throws IOException { + Class srcType = value.getClass(); + String label = subtypeToLabel.get(srcType); + @SuppressWarnings("unchecked") // registration requires that subtype extends T + TypeAdapter delegate = (TypeAdapter) subtypeToDelegate.get(srcType); + if (delegate == null) { + throw new JsonParseException( + "cannot serialize " + srcType.getName() + "; did you forget to register a subtype?"); + } + JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); + if (jsonObject.has(typeFieldName)) { + throw new JsonParseException("cannot serialize " + srcType.getName() + + " because it already defines a field named " + typeFieldName); + } + JsonObject clone = new JsonObject(); + clone.add(typeFieldName, new JsonPrimitive(label)); + for (Map.Entry e : jsonObject.entrySet()) { + clone.add(e.getKey(), e.getValue()); + } + RuntimeTypeAdapterFactory.write(clone, out); + } + }.nullSafe(); + } + + /** + * Takes a reader in any state and returns the next value as a JsonElement. + */ + private static @Nullable JsonElement parse(JsonReader reader) throws JsonParseException { + boolean isEmpty = true; + try { + reader.peek(); + isEmpty = false; + return RuntimeTypeAdapterFactory.JSON_ELEMENT.read(reader); + } catch (EOFException e) { + /* + * For compatibility with JSON 1.5 and earlier, we return a JsonNull for + * empty documents instead of throwing. + */ + if (isEmpty) { + return JsonNull.INSTANCE; + } + // The stream ended prematurely so it is likely a syntax error. + throw new JsonSyntaxException(e); + } catch (MalformedJsonException e) { + throw new JsonSyntaxException(e); + } catch (IOException e) { + throw new JsonIOException(e); + } catch (NumberFormatException e) { + throw new JsonSyntaxException(e); + } + } + + /** + * Writes the JSON element to the writer, recursively. + */ + private static void write(JsonElement element, JsonWriter writer) throws IOException { + RuntimeTypeAdapterFactory.JSON_ELEMENT.write(writer, element); + } + + private static final TypeAdapter JSON_ELEMENT = new TypeAdapter() { + @Override + public @Nullable JsonElement read(@Nullable JsonReader in) throws IOException { + switch (in.peek()) { + case STRING: + return new JsonPrimitive(in.nextString()); + case NUMBER: + String number = in.nextString(); + return new JsonPrimitive(new LazilyParsedNumber(number)); + case BOOLEAN: + return new JsonPrimitive(in.nextBoolean()); + case NULL: + in.nextNull(); + return JsonNull.INSTANCE; + case BEGIN_ARRAY: + JsonArray array = new JsonArray(); + in.beginArray(); + while (in.hasNext()) { + array.add(read(in)); + } + in.endArray(); + return array; + case BEGIN_OBJECT: + JsonObject object = new JsonObject(); + in.beginObject(); + while (in.hasNext()) { + object.add(in.nextName(), read(in)); + } + in.endObject(); + return object; + case END_DOCUMENT: + case NAME: + case END_OBJECT: + case END_ARRAY: + default: + throw new IllegalArgumentException(); + } + } + + @Override + public void write(JsonWriter out, @Nullable JsonElement value) throws IOException { + if (value == null || value.isJsonNull()) { + out.nullValue(); + } else if (value.isJsonPrimitive()) { + JsonPrimitive primitive = value.getAsJsonPrimitive(); + if (primitive.isNumber()) { + out.value(primitive.getAsNumber()); + } else if (primitive.isBoolean()) { + out.value(primitive.getAsBoolean()); + } else { + out.value(primitive.getAsString()); + } + + } else if (value.isJsonArray()) { + out.beginArray(); + for (JsonElement e : value.getAsJsonArray()) { + write(out, e); + } + out.endArray(); + + } else if (value.isJsonObject()) { + out.beginObject(); + for (Map.Entry e : value.getAsJsonObject().entrySet()) { + out.name(e.getKey()); + write(out, e.getValue()); + } + out.endObject(); + + } else { + throw new IllegalArgumentException("Couldn't write " + value.getClass()); + } + } + }; + + /** + * This class holds a number value that is lazily converted to a specific number type + * + * @author Inderjeet Singh + */ + public static final class LazilyParsedNumber extends Number { + private final String value; + + public LazilyParsedNumber(String value) { + this.value = value; + } + + @Override + public int intValue() { + try { + return Integer.parseInt(value); + } catch (NumberFormatException e) { + try { + return (int) Long.parseLong(value); + } catch (NumberFormatException nfe) { + return new BigDecimal(value).intValue(); + } + } + } + + @Override + public long longValue() { + try { + return Long.parseLong(value); + } catch (NumberFormatException e) { + return new BigDecimal(value).longValue(); + } + } + + @Override + public float floatValue() { + return Float.parseFloat(value); + } + + @Override + public double doubleValue() { + return Double.parseDouble(value); + } + + @Override + public String toString() { + return value; + } + + /** + * If somebody is unlucky enough to have to serialize one of these, serialize + * it as a BigDecimal so that they won't need Gson on the other side to + * deserialize it. + */ + private Object writeReplace() throws ObjectStreamException { + return new BigDecimal(value); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java new file mode 100644 index 000000000..496bd2f87 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/TemporalTypeAdapter.java @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.io.IOException; +import java.util.Objects; +import java.util.function.Function; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; + +/** + * Abstract type adapter for jsr310 date-time types. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +abstract class TemporalTypeAdapter extends TypeAdapter { + + Function parseFunction; + + TemporalTypeAdapter(Function parseFunction) { + Objects.requireNonNull(parseFunction); + this.parseFunction = parseFunction; + } + + @Override + public void write(JsonWriter out, @Nullable T value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(value.toString()); + } + } + + @Override + public @Nullable T read(JsonReader in) throws IOException { + if (in.peek() == JsonToken.NULL) { + in.nextNull(); + return null; + } + String temporalString = preProcess(in.nextString()); + return parseFunction.apply(temporalString); + } + + public String preProcess(String in) { + return in; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java new file mode 100644 index 000000000..83b8a9fce --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearMonthTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.YearMonth; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link YearMonth} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class YearMonthTypeAdapter extends TemporalTypeAdapter { + + public YearMonthTypeAdapter() { + super(YearMonth::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearTypeAdapter.java new file mode 100644 index 000000000..bc58f09dc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/YearTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.Year; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link Year} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class YearTypeAdapter extends TemporalTypeAdapter { + + public YearTypeAdapter() { + super(Year::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java new file mode 100644 index 000000000..7ec3303f2 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/common/impl/typeadapters/imported/ZonedDateTimeTypeAdapter.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +/* + * Imported from https://github.com/google-gson/typeadapters/tree/master/jsr310/src + * and repackaged to avoid the default package. + */ +package org.openhab.binding.lametrictime.internal.api.common.impl.typeadapters.imported; + +import java.time.ZonedDateTime; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Type adapter for jsr310 {@link ZonedDateTime} class. + * + * @author Christophe Bornet - Initial contribution + */ +@NonNullByDefault +public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter { + + public ZonedDateTimeTypeAdapter() { + super(ZonedDateTime::parse); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ApiValue.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ApiValue.java new file mode 100644 index 000000000..a3f90e0bb --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ApiValue.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +/** + * Interface for api value. + * + * @author Gregory Moyer - Initial contribution + */ +public interface ApiValue { + public String toRaw(); + + public static String raw(ApiValue value) { + if (value == null) { + return null; + } + + return value.toRaw(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ClockApp.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ClockApp.java new file mode 100644 index 000000000..b075fac55 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/ClockApp.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.openhab.binding.lametrictime.internal.api.local.dto.BooleanParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.Parameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.StringParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Implementation class for the ClockApp. + * + * @author Gregory Moyer - Initial contribution + */ +public class ClockApp extends CoreApplication { + private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("HH:mm:ss"); + + private static final String NAME = "com.lametric.clock"; + + private static final String ACTION_ALARM = "clock.alarm"; + + private static final String PARAMETER_ENABLED = "enabled"; + private static final String PARAMETER_TIME = "time"; + private static final String PARAMETER_WAKE_WITH_RADIO = "wake_with_radio"; + + public ClockApp() { + super(NAME); + } + + public CoreAction setAlarm(Boolean enabled, LocalTime time, Boolean wakeWithRadio) { + SortedMap parameters = new TreeMap<>(); + + if (enabled != null) { + parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(enabled)); + } + + if (time != null) { + parameters.put(PARAMETER_TIME, new StringParameter().withValue(time.format(TIME_FORMATTER))); + } + + if (wakeWithRadio != null) { + parameters.put(PARAMETER_WAKE_WITH_RADIO, new BooleanParameter().withValue(wakeWithRadio)); + } + + return new CoreAction(this, new UpdateAction().withId(ACTION_ALARM).withParameters(parameters)); + } + + public CoreAction stopAlarm() { + SortedMap parameters = new TreeMap<>(); + parameters.put(PARAMETER_ENABLED, new BooleanParameter().withValue(false)); + + return new CoreAction(this, new UpdateAction().withId(ACTION_ALARM).withParameters(parameters)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreAction.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreAction.java new file mode 100644 index 000000000..691693e04 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreAction.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Class for managing the core actions. + * + * @author Gregory Moyer - Initial contribution + */ +public class CoreAction { + private final CoreApplication app; + private final UpdateAction action; + + protected CoreAction(CoreApplication app, UpdateAction action) { + this.app = app; + this.action = action; + } + + public CoreApplication getApp() { + return app; + } + + public UpdateAction getAction() { + return action; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApplication.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApplication.java new file mode 100644 index 000000000..94a3a2fce --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApplication.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +/** + * Abstract class for the core applications. + * + * @author Gregory Moyer - Initial contribution + */ +public abstract class CoreApplication { + private final String packageName; + + public CoreApplication(String packageName) { + this.packageName = packageName; + } + + public String getPackageName() { + return packageName; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApps.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApps.java new file mode 100644 index 000000000..526f07a3c --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CoreApps.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +/** + * Class for managing the core apps. + * + * @author Gregory Moyer - Initial contribution + */ +public class CoreApps { + private static final ClockApp CLOCK = new ClockApp(); + private static final CountdownApp COUNTDOWN = new CountdownApp(); + private static final RadioApp RADIO = new RadioApp(); + private static final StopwatchApp STOPWATCH = new StopwatchApp(); + private static final WeatherApp WEATHER = new WeatherApp(); + + public static ClockApp clock() { + return CLOCK; + } + + public static CountdownApp countdown() { + return COUNTDOWN; + } + + public static RadioApp radio() { + return RADIO; + } + + public static StopwatchApp stopwatch() { + return STOPWATCH; + } + + public static WeatherApp weather() { + return WEATHER; + } + + // @formatter:off + private CoreApps() {} + // @formatter:on +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CountdownApp.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CountdownApp.java new file mode 100644 index 000000000..951e21ed3 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/CountdownApp.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import java.util.SortedMap; +import java.util.TreeMap; + +import org.openhab.binding.lametrictime.internal.api.local.dto.BooleanParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.IntegerParameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.Parameter; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Implementation class for the CountdownApp. + * + * @author Gregory Moyer - Initial contribution + */ +public class CountdownApp extends CoreApplication { + private static final String NAME = "com.lametric.countdown"; + + private static final String ACTION_CONFIGURE = "countdown.configure"; + private static final String ACTION_PAUSE = "countdown.pause"; + private static final String ACTION_RESET = "countdown.reset"; + private static final String ACTION_START = "countdown.start"; + + private static final String PARAMETER_DURATION = "duration"; + private static final String PARAMETER_START_NOW = "start_now"; + + public CountdownApp() { + super(NAME); + } + + public CoreAction configure(int duration, boolean startNow) { + SortedMap parameters = new TreeMap<>(); + parameters.put(PARAMETER_DURATION, new IntegerParameter().withValue(duration)); + parameters.put(PARAMETER_START_NOW, new BooleanParameter().withValue(startNow)); + + return new CoreAction(this, new UpdateAction().withId(ACTION_CONFIGURE).withParameters(parameters)); + } + + public CoreAction pause() { + return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE)); + } + + public CoreAction reset() { + return new CoreAction(this, new UpdateAction().withId(ACTION_RESET)); + } + + public CoreAction start() { + return new CoreAction(this, new UpdateAction().withId(ACTION_START)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icon.java new file mode 100644 index 000000000..20114647f --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icon.java @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +/** + * Marker Interface for icon. + * + * @author Gregory Moyer - Initial contribution + */ +public interface Icon extends ApiValue { + // marker interface +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icons.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icons.java similarity index 61% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icons.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icons.java index df09f78fb..c3f4cdf41 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/Icons.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/Icons.java @@ -1,58 +1,53 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.model; +package org.openhab.binding.lametrictime.internal.api.dto; import java.io.File; import java.net.URI; import java.nio.file.Path; -import org.openhab.binding.lametrictime.api.impl.DataIcon; -import org.openhab.binding.lametrictime.api.impl.FileIcon; -import org.openhab.binding.lametrictime.api.impl.HTTPIcon; -import org.openhab.binding.lametrictime.api.impl.KeyIcon; +import org.openhab.binding.lametrictime.internal.api.impl.DataIcon; +import org.openhab.binding.lametrictime.internal.api.impl.FileIcon; +import org.openhab.binding.lametrictime.internal.api.impl.HTTPIcon; +import org.openhab.binding.lametrictime.internal.api.impl.KeyIcon; -public class Icons -{ - public static Icon key(String key) - { +/** + * Class for managing the core icons. + * + * @author Gregory Moyer - Initial contribution + */ +public class Icons { + public static Icon key(String key) { return new KeyIcon(key); } - public static Icon http(String uri) - { + public static Icon http(String uri) { return http(URI.create(uri)); } - public static Icon http(URI uri) - { + public static Icon http(URI uri) { return new HTTPIcon(uri); } - public static Icon path(Path path) - { + public static Icon path(Path path) { return new FileIcon(path); } - public static Icon file(File file) - { + public static Icon file(File file) { return new FileIcon(file); } - public static Icon data(String mimeType, byte[] data) - { + public static Icon data(String mimeType, byte[] data) { return new DataIcon(mimeType, data); } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/RadioApp.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/RadioApp.java new file mode 100644 index 000000000..e38fbe35e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/RadioApp.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Implementation class for the RadioApp. + * + * @author Gregory Moyer - Initial contribution + */ +public class RadioApp extends CoreApplication { + private static final String NAME = "com.lametric.radio"; + + private static final String ACTION_NEXT = "radio.next"; + private static final String ACTION_PLAY = "radio.play"; + private static final String ACTION_PREV = "radio.prev"; + private static final String ACTION_STOP = "radio.stop"; + + public RadioApp() { + super(NAME); + } + + public CoreAction next() { + return new CoreAction(this, new UpdateAction().withId(ACTION_NEXT)); + } + + public CoreAction play() { + return new CoreAction(this, new UpdateAction().withId(ACTION_PLAY)); + } + + public CoreAction previous() { + return new CoreAction(this, new UpdateAction().withId(ACTION_PREV)); + } + + public CoreAction stop() { + return new CoreAction(this, new UpdateAction().withId(ACTION_STOP)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/StopwatchApp.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/StopwatchApp.java new file mode 100644 index 000000000..247513934 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/StopwatchApp.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Implementation class for the StopwatchApp. + * + * @author Gregory Moyer - Initial contribution + */ +public class StopwatchApp extends CoreApplication { + private static final String NAME = "com.lametric.stopwatch"; + + private static final String ACTION_PAUSE = "stopwatch.pause"; + private static final String ACTION_RESET = "stopwatch.reset"; + private static final String ACTION_START = "stopwatch.start"; + + public StopwatchApp() { + super(NAME); + } + + public CoreAction pause() { + return new CoreAction(this, new UpdateAction().withId(ACTION_PAUSE)); + } + + public CoreAction reset() { + return new CoreAction(this, new UpdateAction().withId(ACTION_RESET)); + } + + public CoreAction start() { + return new CoreAction(this, new UpdateAction().withId(ACTION_START)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/WeatherApp.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/WeatherApp.java new file mode 100644 index 000000000..2a8917a62 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/WeatherApp.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto; + +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; + +/** + * Implementation class for the WeatherApp. + * + * @author Gregory Moyer - Initial contribution + */ +public class WeatherApp extends CoreApplication { + private static final String NAME = "com.lametric.weather"; + + private static final String ACTION_FORECAST = "weather.forecast"; + + public WeatherApp() { + super(NAME); + } + + public CoreAction forecast() { + return new CoreAction(this, new UpdateAction().withId(ACTION_FORECAST)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessMode.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessMode.java new file mode 100644 index 000000000..0b53e63f1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessMode.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for brightness mode. + * + * @author Gregory Moyer - Initial contribution + */ +public enum BrightnessMode implements ApiValue { + AUTO, + MANUAL; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static BrightnessMode toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayType.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayType.java new file mode 100644 index 000000000..87d27c0a1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayType.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for display type. + * + * @author Gregory Moyer - Initial contribution + */ +public enum DisplayType implements ApiValue { + MONOCHROME, + GRAYSCALE, + COLOR, + MIXED; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static DisplayType toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconType.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconType.java new file mode 100644 index 000000000..2a572734e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconType.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for icon type. + * + * @author Gregory Moyer - Initial contribution + */ +public enum IconType implements ApiValue { + NONE, + INFO, + ALERT; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static IconType toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpMode.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpMode.java new file mode 100644 index 000000000..d740446d4 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpMode.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for ip mode. + * + * @author Gregory Moyer - Initial contribution + */ +public enum IpMode implements ApiValue { + STATIC, + DHCP; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static IpMode toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Priority.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Priority.java new file mode 100644 index 000000000..309ebe5d5 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Priority.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for priority. + * + * @author Gregory Moyer - Initial contribution + */ +public enum Priority implements ApiValue { + INFO, + WARNING, + CRITICAL; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static Priority toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Sound.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Sound.java similarity index 67% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Sound.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Sound.java index a9c3ea1b5..c807017b8 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/model/enums/Sound.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/Sound.java @@ -1,24 +1,25 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.model.enums; +package org.openhab.binding.lametrictime.internal.api.dto.enums; -import org.openhab.binding.lametrictime.api.model.ApiValue; +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; -public enum Sound implements ApiValue -{ +/** + * Enum for sound. + * + * @author Gregory Moyer - Initial contribution + */ +public enum Sound implements ApiValue { BICYCLE(SoundCategory.NOTIFICATIONS), CAR(SoundCategory.NOTIFICATIONS), CASH(SoundCategory.NOTIFICATIONS), @@ -72,46 +73,36 @@ public enum Sound implements ApiValue private final SoundCategory category; private final String rawValue; - private Sound(SoundCategory category) - { + private Sound(SoundCategory category) { this(category, null); } - private Sound(SoundCategory category, String rawValue) - { + private Sound(SoundCategory category, String rawValue) { this.category = category; this.rawValue = rawValue; } - public SoundCategory getCategory() - { + public SoundCategory getCategory() { return category; } @Override - public String toRaw() - { + public String toRaw() { return rawValue != null ? rawValue : name().toLowerCase(); } - public static Sound toEnum(String raw) - { - if (raw == null) - { + public static Sound toEnum(String raw) { + if (raw == null) { return null; } - if (KNOCK_KNOCK.rawValue.equals(raw)) - { + if (KNOCK_KNOCK.rawValue.equals(raw)) { return KNOCK_KNOCK; } - try - { + try { return valueOf(raw.toUpperCase()); - } - catch (IllegalArgumentException e) - { + } catch (IllegalArgumentException e) { // not a valid raw string return null; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategory.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategory.java new file mode 100644 index 000000000..0b8380cd3 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategory.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for sound category. + * + * @author Gregory Moyer - Initial contribution + */ +public enum SoundCategory implements ApiValue { + NOTIFICATIONS, + ALARMS; + + @Override + public String toRaw() { + return name().toLowerCase(); + } + + public static SoundCategory toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw.toUpperCase()); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryption.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryption.java new file mode 100644 index 000000000..a98b60d45 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryption.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import org.openhab.binding.lametrictime.internal.api.dto.ApiValue; + +/** + * Enum for wifi encryption. + * + * @author Gregory Moyer - Initial contribution + */ +public enum WifiEncryption implements ApiValue { + OPEN, + WEP, + WPA, + WPA2; + + @Override + public String toRaw() { + return name(); + } + + public static WifiEncryption toEnum(String raw) { + if (raw == null) { + return null; + } + + try { + return valueOf(raw); + } catch (IllegalArgumentException e) { + // not a valid raw string + return null; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/AbstractDataIcon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/AbstractDataIcon.java new file mode 100644 index 000000000..a0485d9fb --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/AbstractDataIcon.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import java.util.Base64; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.Icon; + +/** + * Implementation class for icons. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public abstract class AbstractDataIcon implements Icon { + @Nullable + private volatile Object CONFIGURE_FLAG; + + @Nullable + private String type; + + private byte @Nullable [] data; + + protected void configure() { + if (CONFIGURE_FLAG == null) { + synchronized (this) { + if (CONFIGURE_FLAG == null) { + populateFields(); + } + } + } + } + + protected @Nullable String getType() { + configure(); + return type; + } + + protected void setType(String type) { + this.type = type; + } + + protected byte @Nullable [] getData() { + configure(); + return data; + } + + protected void setData(byte[] data) { + this.data = data; + } + + @Override + public String toRaw() { + return new StringBuilder().append("data:").append(getType()).append(";base64,") + .append(Base64.getEncoder().encodeToString(getData())).toString(); + } + + protected abstract void populateFields(); +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/DataIcon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/DataIcon.java new file mode 100644 index 000000000..357c496a1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/DataIcon.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Implementation class for data icons. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class DataIcon extends AbstractDataIcon { + public DataIcon(String mimeType, byte[] data) { + setType(mimeType); + setData(data); + } + + @Override + protected void configure() { + // noop + } + + @Override + protected void populateFields() { + // noop + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/FileIcon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/FileIcon.java new file mode 100644 index 000000000..8489fe9dc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/FileIcon.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import javax.activation.MimetypesFileTypeMap; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation class for file icons. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class FileIcon extends AbstractDataIcon { + private final Logger logger = LoggerFactory.getLogger(FileIcon.class); + + private final MimetypesFileTypeMap mimeTypeMap = new MimetypesFileTypeMap(); + + private final Path path; + + public FileIcon(File file) { + this(file.toPath()); + } + + public FileIcon(Path path) { + this.path = path; + mimeTypeMap.addMimeTypes("image/png png PNG"); + } + + @Override + protected void populateFields() { + setType(mimeTypeMap.getContentType(path.toFile())); + try { + setData(Files.readAllBytes(path)); + } catch (IOException e) { + logger.warn("Failed reading icon content.", e); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/HTTPIcon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/HTTPIcon.java new file mode 100644 index 000000000..026a5223e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/HTTPIcon.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import java.net.URI; + +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import javax.ws.rs.core.Response; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Implementation class for http icons. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class HTTPIcon extends AbstractDataIcon { + private final URI uri; + + public HTTPIcon(String uri) { + this(URI.create(uri)); + } + + public HTTPIcon(URI uri) { + this.uri = uri; + } + + @Override + protected void populateFields() { + Client client = ClientBuilder.newBuilder().build(); + Response response = client.target(uri).request().get(); + + setType(response.getMediaType().toString()); + setData(response.readEntity(byte[].class)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/KeyIcon.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/KeyIcon.java new file mode 100644 index 000000000..848101810 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/KeyIcon.java @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.dto.Icon; + +/** + * Implementation class for key icons. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class KeyIcon implements Icon { + private final String key; + + public KeyIcon(String key) { + this.key = key; + } + + @Override + public String toRaw() { + return key; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/LaMetricTimeImpl.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/LaMetricTimeImpl.java new file mode 100644 index 000000000..0c8088bdd --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/impl/LaMetricTimeImpl.java @@ -0,0 +1,291 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import static org.openhab.binding.lametrictime.internal.api.dto.ApiValue.raw; + +import java.util.Arrays; + +import javax.ws.rs.client.ClientBuilder; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.Configuration; +import org.openhab.binding.lametrictime.internal.api.LaMetricTime; +import org.openhab.binding.lametrictime.internal.api.cloud.CloudConfiguration; +import org.openhab.binding.lametrictime.internal.api.cloud.LaMetricTimeCloud; +import org.openhab.binding.lametrictime.internal.api.dto.CoreAction; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApplication; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.dto.Icon; +import org.openhab.binding.lametrictime.internal.api.dto.Icons; +import org.openhab.binding.lametrictime.internal.api.dto.enums.BrightnessMode; +import org.openhab.binding.lametrictime.internal.api.dto.enums.Priority; +import org.openhab.binding.lametrictime.internal.api.dto.enums.Sound; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.LaMetricTimeLocal; +import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration; +import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException; +import org.openhab.binding.lametrictime.internal.api.local.UpdateException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.Frame; +import org.openhab.binding.lametrictime.internal.api.local.dto.Notification; +import org.openhab.binding.lametrictime.internal.api.local.dto.NotificationModel; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Implementation class for LaMetricTime interface. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class LaMetricTimeImpl implements LaMetricTime { + + private final Logger logger = LoggerFactory.getLogger(LaMetricTimeImpl.class); + + private final LaMetricTimeLocal local; + private final LaMetricTimeCloud cloud; + + private final Object muteLock = new Object(); + @Nullable + private Integer volumeSaveState; + + public LaMetricTimeImpl(Configuration config) { + this(config.getLocalConfig(), config.getCloudConfig()); + } + + public LaMetricTimeImpl(Configuration config, ClientBuilder clientBuilder) { + this(config.getLocalConfig(), config.getCloudConfig(), clientBuilder); + } + + public LaMetricTimeImpl(LocalConfiguration localConfig, CloudConfiguration cloudConfig) { + this.local = LaMetricTimeLocal.create(localConfig); + this.cloud = LaMetricTimeCloud.create(cloudConfig); + } + + public LaMetricTimeImpl(LocalConfiguration localConfig, CloudConfiguration cloudConfig, + ClientBuilder clientBuilder) { + this.local = LaMetricTimeLocal.create(localConfig, clientBuilder); + this.cloud = LaMetricTimeCloud.create(cloudConfig, clientBuilder); + } + + @Override + public String getVersion() { + return local.getApi().getApiVersion(); + } + + @Override + public String notifyInfo(@Nullable String message) throws NotificationCreationException { + return notify(message, Priority.INFO, Icons.key("i1248"), Sound.NOTIFICATION, 1, 1); + } + + @Override + public String notifyWarning(@Nullable String message) throws NotificationCreationException { + return notify(message, Priority.WARNING, Icons.key("a2098"), Sound.NOTIFICATION2, 2, 2); + } + + @Override + public String notifyCritical(@Nullable String message) throws NotificationCreationException { + return notify(message, Priority.CRITICAL, Icons.key("a4787"), Sound.ALARM1, 0, 0); + } + + @Override + public String notify(@Nullable String message, @Nullable Priority priority, @Nullable Icon icon, + @Nullable Sound sound, int messageRepeat, int soundRepeat) throws NotificationCreationException { + // @formatter:off + NotificationModel model = new NotificationModel() + .withCycles(messageRepeat) + .withFrames(Arrays.asList(new Frame().withText(message) + .withIcon(raw(icon)))); + if (sound != null) + { + model.setSound(new org.openhab.binding.lametrictime.internal.api.local.dto.Sound() + .withCategory(raw(sound.getCategory())) + .withId(raw(sound)) + .withRepeat(soundRepeat)); + } + // @formatter:on + + Notification notification = new Notification().withPriority(raw(priority)).withModel(model); + return local.createNotification(notification); + } + + @Override + public @Nullable Application getClock() { + return getApplication(CoreApps.clock()); + } + + @Override + public @Nullable Application getCountdown() { + return getApplication(CoreApps.countdown()); + } + + @Override + public @Nullable Application getRadio() { + return getApplication(CoreApps.radio()); + } + + @Override + public @Nullable Application getStopwatch() { + return getApplication(CoreApps.stopwatch()); + } + + @Override + public @Nullable Application getWeather() { + return getApplication(CoreApps.weather()); + } + + @Override + public @Nullable Application getApplication(@Nullable CoreApplication coreApp) { + try { + return getLocalApi().getApplication(coreApp.getPackageName()); + } catch (ApplicationNotFoundException e) { + // core apps should never throw errors + logger.error("Failed to retrieve core application: {}", coreApp.getPackageName(), e); + return null; + } + } + + @Override + public @Nullable Application getApplication(@Nullable String name) throws ApplicationNotFoundException { + if (name != null) { + return getLocalApi().getApplication(name); + } else { + return null; + } + } + + @Override + public void activateApplication(@Nullable CoreApplication coreApp) { + try { + activateApplication(getApplication(coreApp)); + } catch (ApplicationActivationException e) { + // core apps should never throw errors + logger.error("Failed to activate core application: {}", coreApp.getPackageName(), e); + } + } + + @Override + public void activateApplication(@Nullable Application app) throws ApplicationActivationException { + getLocalApi().activateApplication(app.getPackageName(), getFirstWidgetId(app)); + } + + @Override + public void activateWidget(@Nullable Widget widget) throws ApplicationActivationException { + getLocalApi().activateApplication(widget.getPackageName(), widget.getId()); + } + + @Override + public void doAction(@Nullable CoreAction coreAction) { + try { + doAction(getApplication(coreAction.getApp()), coreAction.getAction()); + } catch (ApplicationActionException e) { + // core apps should never throw errors + logger.error("Failed to execute weather forecast action", e); + } + } + + @Override + public void doAction(@Nullable Application app, @Nullable UpdateAction action) throws ApplicationActionException { + getLocalApi().doAction(app.getPackageName(), getFirstWidgetId(app), action); + } + + @Override + public void doAction(@Nullable Widget widget, @Nullable CoreAction coreAction) throws ApplicationActionException { + doAction(widget, coreAction.getAction()); + } + + @Override + public void doAction(@Nullable Widget widget, @Nullable UpdateAction action) throws ApplicationActionException { + getLocalApi().doAction(widget.getPackageName(), widget.getId(), action); + } + + protected String getFirstWidgetId(Application app) { + return app.getWidgets().firstKey(); + } + + @Override + public Display setBrightness(int brightness) throws UpdateException { + return local + .updateDisplay(new Display().withBrightness(brightness).withBrightnessMode(raw(BrightnessMode.MANUAL))); + } + + @Override + public Display setBrightnessMode(@Nullable BrightnessMode mode) throws UpdateException { + return local.updateDisplay(new Display().withBrightnessMode(raw(mode))); + } + + @Override + public Audio setVolume(int volume) throws UpdateException { + return local.updateAudio(new Audio().withVolume(volume)); + } + + @Override + public Audio mute() throws UpdateException { + synchronized (muteLock) { + Audio audio = local.getAudio(); + if (audio.getVolume() == 0) { + return audio; + } + + volumeSaveState = audio.getVolume(); + return setVolume(0); + } + } + + @Override + public Audio unmute() throws UpdateException { + synchronized (muteLock) { + if (volumeSaveState == null) { + Audio audio = local.getAudio(); + if (audio.getVolume() == 0) { + return setVolume(50); + } else { + return audio; + } + } + + Audio audio = setVolume(volumeSaveState); + volumeSaveState = null; + return audio; + } + } + + @Override + public Bluetooth setBluetoothActive(boolean active) throws UpdateException { + return local.updateBluetooth(new Bluetooth().withActive(active)); + } + + @Override + public Bluetooth setBluetoothName(@Nullable String name) throws UpdateException { + return local.updateBluetooth(new Bluetooth().withName(name)); + } + + @Override + public LaMetricTimeLocal getLocalApi() { + return local; + } + + @Override + public LaMetricTimeCloud getCloudApi() { + return cloud; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActionException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActionException.java new file mode 100644 index 000000000..c08521bdb --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActionException.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for application action exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class ApplicationActionException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public ApplicationActionException() { + super(); + } + + public ApplicationActionException(String message) { + super(message); + } + + public ApplicationActionException(Throwable cause) { + super(cause); + } + + public ApplicationActionException(String message, Throwable cause) { + super(message, cause); + } + + public ApplicationActionException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public ApplicationActionException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActivationException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActivationException.java new file mode 100644 index 000000000..f14ef5dcc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationActivationException.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for application activation exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class ApplicationActivationException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public ApplicationActivationException() { + super(); + } + + public ApplicationActivationException(String message) { + super(message); + } + + public ApplicationActivationException(Throwable cause) { + super(cause); + } + + public ApplicationActivationException(String message, Throwable cause) { + super(message, cause); + } + + public ApplicationActivationException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public ApplicationActivationException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationNotFoundException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationNotFoundException.java new file mode 100644 index 000000000..96b3ddfd1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/ApplicationNotFoundException.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for application not found exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class ApplicationNotFoundException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public ApplicationNotFoundException() { + super(); + } + + public ApplicationNotFoundException(String message) { + super(message); + } + + public ApplicationNotFoundException(Throwable cause) { + super(cause); + } + + public ApplicationNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public ApplicationNotFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public ApplicationNotFoundException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeException.java new file mode 100644 index 000000000..0af027807 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeException.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import java.util.List; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Error; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Parent class for LaMetricTime exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class LaMetricTimeException extends Exception { + private static final long serialVersionUID = 1L; + + public LaMetricTimeException() { + super(); + } + + public LaMetricTimeException(String message) { + super(message); + } + + public LaMetricTimeException(Throwable cause) { + super(cause); + } + + public LaMetricTimeException(String message, Throwable cause) { + super(message, cause); + } + + public LaMetricTimeException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public LaMetricTimeException(Failure failure) { + super(buildMessage(failure)); + } + + private static String buildMessage(Failure failure) { + StringBuilder builder = new StringBuilder(); + + List errors = failure.getErrors(); + if (!errors.isEmpty()) { + builder.append(errors.get(0).getMessage()); + } + + for (int i = 1; i < errors.size(); i++) { + builder.append("; ").append(errors.get(i).getMessage()); + } + + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeLocal.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeLocal.java new file mode 100644 index 000000000..72bce6484 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LaMetricTimeLocal.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import java.util.List; +import java.util.SortedMap; + +import javax.ws.rs.client.ClientBuilder; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.local.dto.Api; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.Device; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.Notification; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; +import org.openhab.binding.lametrictime.internal.api.local.dto.WidgetUpdates; +import org.openhab.binding.lametrictime.internal.api.local.dto.Wifi; +import org.openhab.binding.lametrictime.internal.api.local.impl.LaMetricTimeLocalImpl; + +/** + * Interface for local device access. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public interface LaMetricTimeLocal { + public Api getApi(); + + public Device getDevice(); + + public String createNotification(Notification notification) throws NotificationCreationException; + + public List getNotifications(); + + public @Nullable Notification getCurrentNotification(); + + public Notification getNotification(String id) throws NotificationNotFoundException; + + public void deleteNotification(String id) throws NotificationNotFoundException; + + public Display getDisplay(); + + public Display updateDisplay(Display display) throws UpdateException; + + public Audio getAudio(); + + public Audio updateAudio(Audio audio) throws UpdateException; + + public Bluetooth getBluetooth(); + + public Bluetooth updateBluetooth(Bluetooth bluetooth) throws UpdateException; + + public Wifi getWifi(); + + public void updateApplication(String packageName, String accessToken, WidgetUpdates widgetUpdates) + throws UpdateException; + + public SortedMap getApplications(); + + public @Nullable Application getApplication(String packageName) throws ApplicationNotFoundException; + + public void activatePreviousApplication(); + + public void activateNextApplication(); + + public void activateApplication(String packageName, String widgetId) throws ApplicationActivationException; + + public void doAction(String packageName, String widgetId, @Nullable UpdateAction action) + throws ApplicationActionException; + + public static LaMetricTimeLocal create(LocalConfiguration config) { + return new LaMetricTimeLocalImpl(config); + } + + public static LaMetricTimeLocal create(LocalConfiguration config, ClientBuilder clientBuilder) { + return new LaMetricTimeLocalImpl(config, clientBuilder); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LocalConfiguration.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LocalConfiguration.java similarity index 54% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LocalConfiguration.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LocalConfiguration.java index 128cea2cd..09580d93f 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/LocalConfiguration.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/LocalConfiguration.java @@ -1,26 +1,34 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local; +package org.openhab.binding.lametrictime.internal.api.local; import java.net.URI; import java.net.URISyntaxException; -public class LocalConfiguration -{ +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + +/** + * Configuration class for local access. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class LocalConfiguration { + @Nullable private String host; + + @Nullable private String apiKey; private boolean secure = true; @@ -41,241 +49,195 @@ public class LocalConfiguration private String logLevel = "INFO"; private int logMax = 104857600; // 100kb - public String getHost() - { + public @Nullable String getHost() { return host; } - public void setHost(String host) - { + public void setHost(String host) { this.host = host; } - public LocalConfiguration withHost(String host) - { + public LocalConfiguration withHost(@Nullable String host) { this.host = host; return this; } - public String getApiKey() - { + public @Nullable String getApiKey() { return apiKey; } - public void setApiKey(String apiKey) - { + public void setApiKey(String apiKey) { this.apiKey = apiKey; } - public LocalConfiguration withApiKey(String apiKey) - { + public LocalConfiguration withApiKey(@Nullable String apiKey) { this.apiKey = apiKey; return this; } - public boolean isSecure() - { + public boolean isSecure() { return secure; } - public void setSecure(boolean secure) - { + public void setSecure(boolean secure) { this.secure = secure; } - public LocalConfiguration withSecure(boolean secure) - { + public LocalConfiguration withSecure(boolean secure) { this.secure = secure; return this; } - public boolean isIgnoreCertificateValidation() - { + public boolean isIgnoreCertificateValidation() { return ignoreCertificateValidation; } - public void setIgnoreCertificateValidation(boolean ignoreCertificateValidation) - { + public void setIgnoreCertificateValidation(boolean ignoreCertificateValidation) { this.ignoreCertificateValidation = ignoreCertificateValidation; } - public LocalConfiguration withIgnoreCertificateValidation(boolean ignoreCertificateValidation) - { + public LocalConfiguration withIgnoreCertificateValidation(boolean ignoreCertificateValidation) { this.ignoreCertificateValidation = ignoreCertificateValidation; return this; } - public boolean isIgnoreHostnameValidation() - { + public boolean isIgnoreHostnameValidation() { return ignoreHostnameValidation; } - public void setIgnoreHostnameValidation(boolean ignoreHostnameValidation) - { + public void setIgnoreHostnameValidation(boolean ignoreHostnameValidation) { this.ignoreHostnameValidation = ignoreHostnameValidation; } - public LocalConfiguration withIgnoreHostnameValidation(boolean ignoreHostnameValidation) - { + public LocalConfiguration withIgnoreHostnameValidation(boolean ignoreHostnameValidation) { this.ignoreHostnameValidation = ignoreHostnameValidation; return this; } - public String getInsecureScheme() - { + public String getInsecureScheme() { return insecureScheme; } - public void setInsecureScheme(String insecureScheme) - { + public void setInsecureScheme(String insecureScheme) { this.insecureScheme = insecureScheme; } - public LocalConfiguration withInsecureScheme(String insecureScheme) - { + public LocalConfiguration withInsecureScheme(String insecureScheme) { this.insecureScheme = insecureScheme; return this; } - public int getInsecurePort() - { + public int getInsecurePort() { return insecurePort; } - public void setInsecurePort(int insecurePort) - { + public void setInsecurePort(int insecurePort) { this.insecurePort = insecurePort; } - public LocalConfiguration withInsecurePort(int insecurePort) - { + public LocalConfiguration withInsecurePort(int insecurePort) { this.insecurePort = insecurePort; return this; } - public String getSecureScheme() - { + public String getSecureScheme() { return secureScheme; } - public void setSecureScheme(String secureScheme) - { + public void setSecureScheme(String secureScheme) { this.secureScheme = secureScheme; } - public LocalConfiguration withSecureScheme(String secureScheme) - { + public LocalConfiguration withSecureScheme(String secureScheme) { this.secureScheme = secureScheme; return this; } - public int getSecurePort() - { + public int getSecurePort() { return securePort; } - public void setSecurePort(int securePort) - { + public void setSecurePort(int securePort) { this.securePort = securePort; } - public LocalConfiguration withSecurePort(int securePort) - { + public LocalConfiguration withSecurePort(int securePort) { this.securePort = securePort; return this; } - public String getBasePath() - { + public String getBasePath() { return basePath; } - public void setBasePath(String basePath) - { + public void setBasePath(String basePath) { this.basePath = basePath; } - public LocalConfiguration withBasePath(String basePath) - { + public LocalConfiguration withBasePath(String basePath) { this.basePath = basePath; return this; } - public String getAuthUser() - { + public String getAuthUser() { return authUser; } - public void setAuthUser(String authUser) - { + public void setAuthUser(String authUser) { this.authUser = authUser; } - public LocalConfiguration withAuthUser(String authUser) - { + public LocalConfiguration withAuthUser(String authUser) { this.authUser = authUser; return this; } - public boolean isLogging() - { + public boolean isLogging() { return logging; } - public void setLogging(boolean logging) - { + public void setLogging(boolean logging) { this.logging = logging; } - public LocalConfiguration withLogging(boolean logging) - { + public LocalConfiguration withLogging(boolean logging) { this.logging = logging; return this; } - public String getLogLevel() - { + public String getLogLevel() { return logLevel; } - public void setLogLevel(String logLevel) - { + public void setLogLevel(String logLevel) { this.logLevel = logLevel; } - public LocalConfiguration withLogLevel(String logLevel) - { + public LocalConfiguration withLogLevel(String logLevel) { this.logLevel = logLevel; return this; } - public int getLogMax() - { + public int getLogMax() { return logMax; } - public void setLogMax(int logMax) - { + public void setLogMax(int logMax) { this.logMax = logMax; } - public LocalConfiguration withLogMax(int logMax) - { + public LocalConfiguration withLogMax(int logMax) { this.logMax = logMax; return this; } - public URI getBaseUri() - { + public URI getBaseUri() { String scheme = secure ? secureScheme : insecureScheme; int port = secure ? securePort : insecurePort; - try - { + try { return new URI(scheme, null, host, port, basePath, null, null); - } - catch (URISyntaxException e) - { - throw new RuntimeException("Invalid configuration", e); + } catch (URISyntaxException e) { + throw new IllegalStateException("Invalid configuration", e); } } } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationCreationException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationCreationException.java new file mode 100644 index 000000000..7848c5436 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationCreationException.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for notification creation exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class NotificationCreationException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public NotificationCreationException() { + super(); + } + + public NotificationCreationException(String message) { + super(message); + } + + public NotificationCreationException(Throwable cause) { + super(cause); + } + + public NotificationCreationException(String message, Throwable cause) { + super(message, cause); + } + + public NotificationCreationException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public NotificationCreationException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationNotFoundException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationNotFoundException.java new file mode 100644 index 000000000..a873a32a2 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/NotificationNotFoundException.java @@ -0,0 +1,51 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for notification not found exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class NotificationNotFoundException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public NotificationNotFoundException() { + super(); + } + + public NotificationNotFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public NotificationNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public NotificationNotFoundException(String message) { + super(message); + } + + public NotificationNotFoundException(Throwable cause) { + super(cause); + } + + public NotificationNotFoundException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/UpdateException.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/UpdateException.java new file mode 100644 index 000000000..7bc5905bc --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/UpdateException.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; + +/** + * Implementation class for update exceptions. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class UpdateException extends LaMetricTimeException { + private static final long serialVersionUID = 1L; + + public UpdateException() { + super(); + } + + public UpdateException(String message) { + super(message); + } + + public UpdateException(Throwable cause) { + super(cause); + } + + public UpdateException(String message, Throwable cause) { + super(message, cause); + } + + public UpdateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public UpdateException(Failure failure) { + super(failure); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Action.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Action.java new file mode 100644 index 000000000..a930a60bd --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Action.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import java.util.SortedMap; + +import com.google.gson.annotations.SerializedName; + +/** + * Pojo for action. + * + * @author Gregory Moyer - Initial contribution + */ +public class Action { + private String id; + @SerializedName("params") + private SortedMap parameters; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Action withId(String id) { + setId(id); + return this; + } + + public SortedMap getParameters() { + return parameters; + } + + public void setParameters(SortedMap parameters) { + this.parameters = parameters; + } + + public Action withParameters(SortedMap parameters) { + setParameters(parameters); + return this; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((parameters == null) ? 0 : parameters.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Action other = (Action) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + if (parameters == null) { + if (other.parameters != null) { + return false; + } + } else if (!parameters.equals(other.parameters)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Action [id="); + builder.append(id); + builder.append(", parameters="); + builder.append(parameters); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Api.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Api.java new file mode 100644 index 000000000..361ba0d56 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Api.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for api. + * + * @author Gregory Moyer - Initial contribution + */ +public class Api { + private String apiVersion; + private Endpoints endpoints; + + public String getApiVersion() { + return apiVersion; + } + + public void setApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + } + + public Api withApiVersion(String apiVersion) { + this.apiVersion = apiVersion; + return this; + } + + public Endpoints getEndpoints() { + return endpoints; + } + + public void setEndpoints(Endpoints endpoints) { + this.endpoints = endpoints; + } + + public Api withEndpoints(Endpoints endpoints) { + this.endpoints = endpoints; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Api [apiVersion="); + builder.append(apiVersion); + builder.append(", endpoints="); + builder.append(endpoints); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Application.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Application.java similarity index 52% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Application.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Application.java index 487a9ff61..c5b4a4fed 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Application.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Application.java @@ -1,26 +1,27 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import java.util.SortedMap; import com.google.gson.annotations.SerializedName; -public class Application -{ +/** + * Pojo for application. + * + * @author Gregory Moyer - Initial contribution + */ +public class Application { private SortedMap actions; @SerializedName("package") private String packageName; @@ -29,105 +30,86 @@ public class Application private String versionCode; private SortedMap widgets; - public SortedMap getActions() - { + public SortedMap getActions() { return actions; } - public void setActions(SortedMap actions) - { + public void setActions(SortedMap actions) { this.actions = actions; } - public Application withActions(SortedMap actions) - { + public Application withActions(SortedMap actions) { setActions(actions); return this; } - public String getPackageName() - { + public String getPackageName() { return packageName; } - public void setPackageName(String packageName) - { + public void setPackageName(String packageName) { this.packageName = packageName; } - public Application withPackageName(String packageName) - { + public Application withPackageName(String packageName) { setPackageName(packageName); return this; } - public String getVendor() - { + public String getVendor() { return vendor; } - public void setVendor(String vendor) - { + public void setVendor(String vendor) { this.vendor = vendor; } - public Application withVendor(String vendor) - { + public Application withVendor(String vendor) { setVendor(vendor); return this; } - public String getVersion() - { + public String getVersion() { return version; } - public void setVersion(String version) - { + public void setVersion(String version) { this.version = version; } - public Application withVersion(String version) - { + public Application withVersion(String version) { setVersion(version); return this; } - public String getVersionCode() - { + public String getVersionCode() { return versionCode; } - public void setVersionCode(String versionCode) - { + public void setVersionCode(String versionCode) { this.versionCode = versionCode; } - public Application withVersionCode(String versionCode) - { + public Application withVersionCode(String versionCode) { setVersionCode(versionCode); return this; } - public SortedMap getWidgets() - { + public SortedMap getWidgets() { return widgets; } - public void setWidgets(SortedMap widgets) - { + public void setWidgets(SortedMap widgets) { this.widgets = widgets; } - public Application withWidgets(SortedMap widgets) - { + public Application withWidgets(SortedMap widgets) { setWidgets(widgets); return this; } @Override - public int hashCode() - { + public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((packageName == null) ? 0 : packageName.hashCode()); @@ -136,49 +118,36 @@ public class Application } @Override - public boolean equals(Object obj) - { - if (this == obj) - { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (obj == null) - { + if (obj == null) { return false; } - if (getClass() != obj.getClass()) - { + if (getClass() != obj.getClass()) { return false; } - Application other = (Application)obj; - if (packageName == null) - { - if (other.packageName != null) - { + Application other = (Application) obj; + if (packageName == null) { + if (other.packageName != null) { return false; } - } - else if (!packageName.equals(other.packageName)) - { + } else if (!packageName.equals(other.packageName)) { return false; } - if (versionCode == null) - { - if (other.versionCode != null) - { + if (versionCode == null) { + if (other.versionCode != null) { return false; } - } - else if (!versionCode.equals(other.versionCode)) - { + } else if (!versionCode.equals(other.versionCode)) { return false; } return true; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Application [actions="); builder.append(actions); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Audio.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Audio.java new file mode 100644 index 000000000..b2db22c06 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Audio.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for audio. + * + * @author Gregory Moyer - Initial contribution + */ +public class Audio { + private Integer volume; + + public Integer getVolume() { + return volume; + } + + public void setVolume(Integer volume) { + this.volume = volume; + } + + public Audio withVolume(Integer volume) { + this.volume = volume; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Audio [volume="); + builder.append(volume); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioUpdateResult.java new file mode 100644 index 000000000..898117fb8 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioUpdateResult.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for audio update result. + * + * @author Gregory Moyer - Initial contribution + */ +public class AudioUpdateResult { + private Success success; + + public Success getSuccess() { + return success; + } + + public void setSuccess(Success success) { + this.success = success; + } + + public AudioUpdateResult withSuccess(Success success) { + this.success = success; + return this; + } + + public static class Success { + private Audio data; + + public Audio getData() { + return data; + } + + public void setData(Audio data) { + this.data = data; + } + + public Success withData(Audio data) { + this.data = data; + return this; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Bluetooth.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Bluetooth.java similarity index 55% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Bluetooth.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Bluetooth.java index 83f1f16d2..03217a6d7 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Bluetooth.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Bluetooth.java @@ -1,22 +1,23 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -public class Bluetooth -{ +/** + * Pojo for bluetooth. + * + * @author Gregory Moyer - Initial contribution + */ +public class Bluetooth { private Boolean active; /* @@ -34,106 +35,87 @@ public class Bluetooth private String name; private Boolean pairable; - public Boolean isActive() - { + public Boolean isActive() { return active; } - public void setActive(Boolean active) - { + public void setActive(Boolean active) { this.active = active; } - public Bluetooth withActive(Boolean active) - { + public Bluetooth withActive(Boolean active) { this.active = active; return this; } - public String getMac() - { + public String getMac() { return mac == null ? address : mac; } - public void setMac(String mac) - { + public void setMac(String mac) { this.mac = mac; this.address = mac; } - public Bluetooth withMac(String mac) - { + public Bluetooth withMac(String mac) { setMac(mac); return this; } - public Boolean isAvailable() - { + public Boolean isAvailable() { return available; } - public void setAvailable(Boolean available) - { + public void setAvailable(Boolean available) { this.available = available; } - public Bluetooth withAvailable(Boolean available) - { + public Bluetooth withAvailable(Boolean available) { this.available = available; return this; } - public Boolean isDiscoverable() - { + public Boolean isDiscoverable() { return discoverable; } - public void setDiscoverable(Boolean discoverable) - { + public void setDiscoverable(Boolean discoverable) { this.discoverable = discoverable; } - public Bluetooth withDiscoverable(Boolean discoverable) - { + public Bluetooth withDiscoverable(Boolean discoverable) { this.discoverable = discoverable; return this; } - public String getName() - { + public String getName() { return name; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } - public Bluetooth withName(String name) - { + public Bluetooth withName(String name) { this.name = name; return this; } - public Boolean isPairable() - { + public Boolean isPairable() { return pairable; } - public void setPairable(Boolean pairable) - { + public void setPairable(Boolean pairable) { this.pairable = pairable; } - public Bluetooth withPairable(Boolean pairable) - { + public Bluetooth withPairable(Boolean pairable) { this.pairable = pairable; return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Bluetooth [active="); builder.append(active); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothUpdateResult.java new file mode 100644 index 000000000..258ea11f0 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothUpdateResult.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for bluetooth update result. + * + * @author Gregory Moyer - Initial contribution + */ +public class BluetoothUpdateResult { + private Success success; + + public Success getSuccess() { + return success; + } + + public void setSuccess(Success success) { + this.success = success; + } + + public BluetoothUpdateResult withSuccess(Success success) { + this.success = success; + return this; + } + + public static class Success { + private Bluetooth data; + + public Bluetooth getData() { + return data; + } + + public void setData(Bluetooth data) { + this.data = data; + } + + public Success withData(Bluetooth data) { + this.data = data; + return this; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BooleanParameter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BooleanParameter.java new file mode 100644 index 000000000..cea6abe4f --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/BooleanParameter.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for boolean parameter. + * + * @author Gregory Moyer - Initial contribution + */ +public class BooleanParameter extends Parameter { + private Boolean value; + + @Override + public BooleanParameter withName(String name) { + super.withName(name); + return this; + } + + @Override + public BooleanParameter withRequired(Boolean required) { + super.withRequired(required); + return this; + } + + public Boolean getValue() { + return value; + } + + public void setValue(Boolean value) { + this.value = value; + } + + public BooleanParameter withValue(Boolean value) { + setValue(value); + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("BooleanParameter [value="); + builder.append(value); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getRequired()="); + builder.append(getRequired()); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Device.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Device.java similarity index 53% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Device.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Device.java index 61ca40a44..d7e951f8e 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Device.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Device.java @@ -1,22 +1,23 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -public class Device -{ +/** + * Pojo for device. + * + * @author Gregory Moyer - Initial contribution + */ +public class Device { private Audio audio; private Bluetooth bluetooth; private Display display; @@ -28,169 +29,138 @@ public class Device private String serialNumber; private Wifi wifi; - public Audio getAudio() - { + public Audio getAudio() { return audio; } - public void setAudio(Audio audio) - { + public void setAudio(Audio audio) { this.audio = audio; } - public Device withAudio(Audio audio) - { + public Device withAudio(Audio audio) { this.audio = audio; return this; } - public Bluetooth getBluetooth() - { + public Bluetooth getBluetooth() { return bluetooth; } - public void setBluetooth(Bluetooth bluetooth) - { + public void setBluetooth(Bluetooth bluetooth) { this.bluetooth = bluetooth; } - public Device withBluetooth(Bluetooth bluetooth) - { + public Device withBluetooth(Bluetooth bluetooth) { this.bluetooth = bluetooth; return this; } - public Display getDisplay() - { + public Display getDisplay() { return display; } - public void setDisplay(Display display) - { + public void setDisplay(Display display) { this.display = display; } - public Device withDisplay(Display display) - { + public Device withDisplay(Display display) { this.display = display; return this; } - public String getId() - { + public String getId() { return id; } - public void setId(String id) - { + public void setId(String id) { this.id = id; } - public Device withId(String id) - { + public Device withId(String id) { this.id = id; return this; } - public String getMode() - { + public String getMode() { return mode; } - public void setMode(String mode) - { + public void setMode(String mode) { this.mode = mode; } - public Device withMode(String mode) - { + public Device withMode(String mode) { this.mode = mode; return this; } - public String getModel() - { + public String getModel() { return model; } - public void setModel(String model) - { + public void setModel(String model) { this.model = model; } - public Device withModel(String model) - { + public Device withModel(String model) { this.model = model; return this; } - public String getName() - { + public String getName() { return name; } - public void setName(String name) - { + public void setName(String name) { this.name = name; } - public Device withName(String name) - { + public Device withName(String name) { this.name = name; return this; } - public String getOsVersion() - { + public String getOsVersion() { return osVersion; } - public void setOsVersion(String osVersion) - { + public void setOsVersion(String osVersion) { this.osVersion = osVersion; } - public Device withOsVersion(String osVersion) - { + public Device withOsVersion(String osVersion) { this.osVersion = osVersion; return this; } - public String getSerialNumber() - { + public String getSerialNumber() { return serialNumber; } - public void setSerialNumber(String serialNumber) - { + public void setSerialNumber(String serialNumber) { this.serialNumber = serialNumber; } - public Device withSerialNumber(String serialNumber) - { + public Device withSerialNumber(String serialNumber) { this.serialNumber = serialNumber; return this; } - public Wifi getWifi() - { + public Wifi getWifi() { return wifi; } - public void setWifi(Wifi wifi) - { + public void setWifi(Wifi wifi) { this.wifi = wifi; } - public Device withWifi(Wifi wifi) - { + public Device withWifi(Wifi wifi) { this.wifi = wifi; return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Device [audio="); builder.append(audio); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Display.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Display.java new file mode 100644 index 000000000..672681fc9 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Display.java @@ -0,0 +1,124 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for display. + * + * @author Gregory Moyer - Initial contribution + */ +public class Display { + private Integer brightness; + private String brightnessMode; + private Integer height; + private Screensaver screensaver; + private String type; + private Integer width; + + public Integer getBrightness() { + return brightness; + } + + public void setBrightness(Integer brightness) { + this.brightness = brightness; + } + + public Display withBrightness(Integer brightness) { + this.brightness = brightness; + return this; + } + + public String getBrightnessMode() { + return brightnessMode; + } + + public void setBrightnessMode(String brightnessMode) { + this.brightnessMode = brightnessMode; + } + + public Display withBrightnessMode(String brightnessMode) { + this.brightnessMode = brightnessMode; + return this; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + public Display withHeight(Integer height) { + this.height = height; + return this; + } + + public Screensaver getScreensaver() { + return screensaver; + } + + public void setScreensaver(Screensaver screensaver) { + this.screensaver = screensaver; + } + + public Display withScreensaver(Screensaver screensaver) { + this.screensaver = screensaver; + return this; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Display withType(String type) { + this.type = type; + return this; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Display withWidth(Integer width) { + this.width = width; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Display [brightness="); + builder.append(brightness); + builder.append(", brightnessMode="); + builder.append(brightnessMode); + builder.append(", height="); + builder.append(height); + builder.append(", screensaver="); + builder.append(screensaver); + builder.append(", type="); + builder.append(type); + builder.append(", width="); + builder.append(width); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/DisplayUpdateResult.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/DisplayUpdateResult.java new file mode 100644 index 000000000..578178b90 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/DisplayUpdateResult.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for display update result. + * + * @author Gregory Moyer - Initial contribution + */ +public class DisplayUpdateResult { + private Success success; + + public Success getSuccess() { + return success; + } + + public void setSuccess(Success success) { + this.success = success; + } + + public DisplayUpdateResult withSuccess(Success success) { + this.success = success; + return this; + } + + public static class Success { + private Display data; + + public Display getData() { + return data; + } + + public void setData(Display data) { + this.data = data; + } + + public Success withData(Display data) { + this.data = data; + return this; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Endpoints.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Endpoints.java similarity index 63% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Endpoints.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Endpoints.java index 827feb4c7..64381c59c 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Endpoints.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Endpoints.java @@ -1,22 +1,23 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -public class Endpoints -{ +/** + * Pojo for endpoints. + * + * @author Gregory Moyer - Initial contribution + */ +public class Endpoints { private String appsActionUrl; private String appsGetUrl; private String appsListUrl; @@ -33,249 +34,203 @@ public class Endpoints private String widgetUpdateUrl; private String wifiUrl; - public String getAppsActionUrl() - { + public String getAppsActionUrl() { return appsActionUrl; } - public void setAppsActionUrl(String appsActionUrl) - { + public void setAppsActionUrl(String appsActionUrl) { this.appsActionUrl = appsActionUrl; } - public Endpoints withAppsActionUrl(String appsActionUrl) - { + public Endpoints withAppsActionUrl(String appsActionUrl) { this.appsActionUrl = appsActionUrl; return this; } - public String getAppsGetUrl() - { + public String getAppsGetUrl() { return appsGetUrl; } - public void setAppsGetUrl(String appsGetUrl) - { + public void setAppsGetUrl(String appsGetUrl) { this.appsGetUrl = appsGetUrl; } - public Endpoints withAppsGetUrl(String appsGetUrl) - { + public Endpoints withAppsGetUrl(String appsGetUrl) { this.appsGetUrl = appsGetUrl; return this; } - public String getAppsListUrl() - { + public String getAppsListUrl() { return appsListUrl; } - public void setAppsListUrl(String appsListUrl) - { + public void setAppsListUrl(String appsListUrl) { this.appsListUrl = appsListUrl; } - public Endpoints withAppsListUrl(String appsListUrl) - { + public Endpoints withAppsListUrl(String appsListUrl) { this.appsListUrl = appsListUrl; return this; } - public String getAppsSwitchNextUrl() - { + public String getAppsSwitchNextUrl() { return appsSwitchNextUrl; } - public void setAppsSwitchNextUrl(String appsSwitchNextUrl) - { + public void setAppsSwitchNextUrl(String appsSwitchNextUrl) { this.appsSwitchNextUrl = appsSwitchNextUrl; } - public Endpoints withAppsSwitchNextUrl(String appsSwitchNextUrl) - { + public Endpoints withAppsSwitchNextUrl(String appsSwitchNextUrl) { this.appsSwitchNextUrl = appsSwitchNextUrl; return this; } - public String getAppsSwitchPrevUrl() - { + public String getAppsSwitchPrevUrl() { return appsSwitchPrevUrl; } - public void setAppsSwitchPrevUrl(String appsSwitchPrevUrl) - { + public void setAppsSwitchPrevUrl(String appsSwitchPrevUrl) { this.appsSwitchPrevUrl = appsSwitchPrevUrl; } - public Endpoints withAppsSwitchPrevUrl(String appsSwitchPrevUrl) - { + public Endpoints withAppsSwitchPrevUrl(String appsSwitchPrevUrl) { this.appsSwitchPrevUrl = appsSwitchPrevUrl; return this; } - public String getAppsSwitchUrl() - { + public String getAppsSwitchUrl() { return appsSwitchUrl; } - public void setAppsSwitchUrl(String appsSwitchUrl) - { + public void setAppsSwitchUrl(String appsSwitchUrl) { this.appsSwitchUrl = appsSwitchUrl; } - public Endpoints withAppsSwitchUrl(String appsSwitchUrl) - { + public Endpoints withAppsSwitchUrl(String appsSwitchUrl) { this.appsSwitchUrl = appsSwitchUrl; return this; } - public String getAudioUrl() - { + public String getAudioUrl() { return audioUrl; } - public void setAudioUrl(String audioUrl) - { + public void setAudioUrl(String audioUrl) { this.audioUrl = audioUrl; } - public Endpoints withAudioUrl(String audioUrl) - { + public Endpoints withAudioUrl(String audioUrl) { this.audioUrl = audioUrl; return this; } - public String getBluetoothUrl() - { + public String getBluetoothUrl() { return bluetoothUrl; } - public void setBluetoothUrl(String bluetoothUrl) - { + public void setBluetoothUrl(String bluetoothUrl) { this.bluetoothUrl = bluetoothUrl; } - public Endpoints withBluetoothUrl(String bluetoothUrl) - { + public Endpoints withBluetoothUrl(String bluetoothUrl) { this.bluetoothUrl = bluetoothUrl; return this; } - public String getConcreteNotificationUrl() - { + public String getConcreteNotificationUrl() { return concreteNotificationUrl; } - public void setConcreteNotificationUrl(String concreteNotificationUrl) - { + public void setConcreteNotificationUrl(String concreteNotificationUrl) { this.concreteNotificationUrl = concreteNotificationUrl; } - public Endpoints withConcreteNotificationUrl(String concreteNotificationUrl) - { + public Endpoints withConcreteNotificationUrl(String concreteNotificationUrl) { this.concreteNotificationUrl = concreteNotificationUrl; return this; } - public String getCurrentNotificationUrl() - { + public String getCurrentNotificationUrl() { return currentNotificationUrl; } - public void setCurrentNotificationUrl(String currentNotificationUrl) - { + public void setCurrentNotificationUrl(String currentNotificationUrl) { this.currentNotificationUrl = currentNotificationUrl; } - public Endpoints withCurrentNotificationUrl(String currentNotificationUrl) - { + public Endpoints withCurrentNotificationUrl(String currentNotificationUrl) { this.currentNotificationUrl = currentNotificationUrl; return this; } - public String getDeviceUrl() - { + public String getDeviceUrl() { return deviceUrl; } - public void setDeviceUrl(String deviceUrl) - { + public void setDeviceUrl(String deviceUrl) { this.deviceUrl = deviceUrl; } - public Endpoints withDeviceUrl(String deviceUrl) - { + public Endpoints withDeviceUrl(String deviceUrl) { this.deviceUrl = deviceUrl; return this; } - public String getDisplayUrl() - { + public String getDisplayUrl() { return displayUrl; } - public void setDisplayUrl(String displayUrl) - { + public void setDisplayUrl(String displayUrl) { this.displayUrl = displayUrl; } - public Endpoints withDisplayUrl(String displayUrl) - { + public Endpoints withDisplayUrl(String displayUrl) { this.displayUrl = displayUrl; return this; } - public String getNotificationsUrl() - { + public String getNotificationsUrl() { return notificationsUrl; } - public void setNotificationsUrl(String notificationsUrl) - { + public void setNotificationsUrl(String notificationsUrl) { this.notificationsUrl = notificationsUrl; } - public Endpoints withNotificationsUrl(String notificationsUrl) - { + public Endpoints withNotificationsUrl(String notificationsUrl) { this.notificationsUrl = notificationsUrl; return this; } - public String getWidgetUpdateUrl() - { + public String getWidgetUpdateUrl() { return widgetUpdateUrl; } - public void setWidgetUpdateUrl(String widgetUpdateUrl) - { + public void setWidgetUpdateUrl(String widgetUpdateUrl) { this.widgetUpdateUrl = widgetUpdateUrl; } - public Endpoints withWidgetUpdateUrl(String widgetUpdateUrl) - { + public Endpoints withWidgetUpdateUrl(String widgetUpdateUrl) { this.widgetUpdateUrl = widgetUpdateUrl; return this; } - public String getWifiUrl() - { + public String getWifiUrl() { return wifiUrl; } - public void setWifiUrl(String wifiUrl) - { + public void setWifiUrl(String wifiUrl) { this.wifiUrl = wifiUrl; } - public Endpoints withWifiUrl(String wifiUrl) - { + public Endpoints withWifiUrl(String wifiUrl) { this.wifiUrl = wifiUrl; return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Endpoints [appsActionUrl="); builder.append(appsActionUrl); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Error.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Error.java new file mode 100644 index 000000000..fa87d026e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Error.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for error. + * + * @author Gregory Moyer - Initial contribution + */ +public class Error { + private String message; + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Error withMessage(String message) { + this.message = message; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Error [message="); + builder.append(message); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Failure.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Failure.java new file mode 100644 index 000000000..0612f3147 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Failure.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import java.util.ArrayList; +import java.util.List; + +/** + * Pojo for failure. + * + * @author Gregory Moyer - Initial contribution + */ +public class Failure { + private List errors = new ArrayList(); + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } + + public Failure withErrors(List errors) { + this.errors = errors; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Failure [errors="); + builder.append(errors); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Frame.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Frame.java similarity index 50% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Frame.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Frame.java index 4e490830e..e1c770d70 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Frame.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Frame.java @@ -1,26 +1,27 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import java.util.List; import com.google.gson.annotations.SerializedName; -public class Frame -{ +/** + * Pojo for frame. + * + * @author Gregory Moyer - Initial contribution + */ +public class Frame { private String icon; private String text; @SerializedName("goalData") @@ -29,89 +30,73 @@ public class Frame private List chartData; private Integer index; - public String getIcon() - { + public String getIcon() { return icon; } - public void setIcon(String icon) - { + public void setIcon(String icon) { this.icon = icon; } - public Frame withIcon(String icon) - { + public Frame withIcon(String icon) { this.icon = icon; return this; } - public String getText() - { + public String getText() { return text; } - public void setText(String text) - { + public void setText(String text) { this.text = text; } - public Frame withText(String text) - { + public Frame withText(String text) { this.text = text; return this; } - public GoalData getGoalData() - { + public GoalData getGoalData() { return goalData; } - public void setGoalData(GoalData goalData) - { + public void setGoalData(GoalData goalData) { this.goalData = goalData; } - public Frame withGoalData(GoalData goalData) - { + public Frame withGoalData(GoalData goalData) { this.goalData = goalData; return this; } - public List getChartData() - { + public List getChartData() { return chartData; } - public void setChartData(List chartData) - { + public void setChartData(List chartData) { this.chartData = chartData; } - public Frame withChartData(List chartData) - { + public Frame withChartData(List chartData) { this.chartData = chartData; return this; } - public Integer getIndex() - { + public Integer getIndex() { return index; } - public void setIndex(Integer index) - { + public void setIndex(Integer index) { this.index = index; } - public Frame withIndex(Integer index) - { + public Frame withIndex(Integer index) { this.index = index; return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Frame [icon="); builder.append(icon); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalData.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalData.java new file mode 100644 index 000000000..f78f016c0 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalData.java @@ -0,0 +1,146 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for goal data. + * + * @author Gregory Moyer - Initial contribution + */ +public class GoalData { + private Integer start; + private Integer current; + private Integer end; + private String unit; + + public Integer getStart() { + return start; + } + + public void setStart(Integer start) { + this.start = start; + } + + public GoalData withStart(Integer start) { + this.start = start; + return this; + } + + public Integer getCurrent() { + return current; + } + + public void setCurrent(Integer current) { + this.current = current; + } + + public GoalData withCurrent(Integer current) { + this.current = current; + return this; + } + + public Integer getEnd() { + return end; + } + + public void setEnd(Integer end) { + this.end = end; + } + + public GoalData withEnd(Integer end) { + this.end = end; + return this; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public GoalData withUnit(String unit) { + this.unit = unit; + return this; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((current == null) ? 0 : current.hashCode()); + result = prime * result + ((end == null) ? 0 : end.hashCode()); + result = prime * result + ((start == null) ? 0 : start.hashCode()); + result = prime * result + ((unit == null) ? 0 : unit.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + GoalData other = (GoalData) obj; + if (current == null) { + if (other.current != null) { + return false; + } + } else if (!current.equals(other.current)) { + return false; + } + if (end == null) { + if (other.end != null) { + return false; + } + } else if (!end.equals(other.end)) { + return false; + } + if (start == null) { + if (other.start != null) { + return false; + } + } else if (!start.equals(other.start)) { + return false; + } + if (unit == null) { + if (other.unit != null) { + return false; + } + } else if (!unit.equals(other.unit)) { + return false; + } + return true; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("GoalData [start="); + builder.append(start); + builder.append(", current="); + builder.append(current); + builder.append(", end="); + builder.append(end); + builder.append(", unit="); + builder.append(unit); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/IntegerParameter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/IntegerParameter.java new file mode 100644 index 000000000..9c5291de4 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/IntegerParameter.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for integer parameter. + * + * @author Gregory Moyer - Initial contribution + */ +public class IntegerParameter extends Parameter { + private Integer value; + + @Override + public IntegerParameter withName(String name) { + super.withName(name); + return this; + } + + @Override + public IntegerParameter withRequired(Boolean required) { + super.withRequired(required); + return this; + } + + public Integer getValue() { + return value; + } + + public void setValue(Integer value) { + this.value = value; + } + + public IntegerParameter withValue(Integer value) { + setValue(value); + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("IntegerParameter [value="); + builder.append(value); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getRequired()="); + builder.append(getRequired()); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Modes.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Modes.java new file mode 100644 index 000000000..7735c62af --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Modes.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for modes. + * + * @author Gregory Moyer - Initial contribution + */ +public class Modes { + private TimeBased timeBased; + private WhenDark whenDark; + + public TimeBased getTimeBased() { + return timeBased; + } + + public void setTimeBased(TimeBased timeBased) { + this.timeBased = timeBased; + } + + public Modes withTimeBased(TimeBased timeBased) { + this.timeBased = timeBased; + return this; + } + + public WhenDark getWhenDark() { + return whenDark; + } + + public void setWhenDark(WhenDark whenDark) { + this.whenDark = whenDark; + } + + public Modes withWhenDark(WhenDark whenDark) { + this.whenDark = whenDark; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Modes [timeBased="); + builder.append(timeBased); + builder.append(", whenDark="); + builder.append(whenDark); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Notification.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Notification.java similarity index 52% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Notification.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Notification.java index f0a57e097..02ab0df0a 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Notification.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Notification.java @@ -1,24 +1,25 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import java.time.LocalDateTime; -public class Notification -{ +/** + * Pojo for notification. + * + * @author Gregory Moyer - Initial contribution + */ +public class Notification { private String id; private String type; private LocalDateTime created; @@ -28,137 +29,112 @@ public class Notification private Integer lifetime; private NotificationModel model; - public String getId() - { + public String getId() { return id; } - public void setId(String id) - { + public void setId(String id) { this.id = id; } - public Notification withId(String id) - { + public Notification withId(String id) { this.id = id; return this; } - public String getType() - { + public String getType() { return type; } - public void setType(String type) - { + public void setType(String type) { this.type = type; } - public Notification withType(String type) - { + public Notification withType(String type) { this.type = type; return this; } - public LocalDateTime getCreated() - { + public LocalDateTime getCreated() { return created; } - public void setCreated(LocalDateTime created) - { + public void setCreated(LocalDateTime created) { this.created = created; } - public Notification withCreated(LocalDateTime created) - { + public Notification withCreated(LocalDateTime created) { this.created = created; return this; } - public LocalDateTime getExpirationDate() - { + public LocalDateTime getExpirationDate() { return expirationDate; } - public void setExpirationDate(LocalDateTime expirationDate) - { + public void setExpirationDate(LocalDateTime expirationDate) { this.expirationDate = expirationDate; } - public Notification withExpirationDate(LocalDateTime expirationDate) - { + public Notification withExpirationDate(LocalDateTime expirationDate) { this.expirationDate = expirationDate; return this; } - public String getPriority() - { + public String getPriority() { return priority; } - public void setPriority(String priority) - { + public void setPriority(String priority) { this.priority = priority; } - public Notification withPriority(String priority) - { + public Notification withPriority(String priority) { this.priority = priority; return this; } - public String getIconType() - { + public String getIconType() { return iconType; } - public void setIconType(String iconType) - { + public void setIconType(String iconType) { this.iconType = iconType; } - public Notification withIconType(String iconType) - { + public Notification withIconType(String iconType) { this.iconType = iconType; return this; } - public Integer getLifetime() - { + public Integer getLifetime() { return lifetime; } - public void setLifetime(Integer lifetime) - { + public void setLifetime(Integer lifetime) { this.lifetime = lifetime; } - public Notification withLifetime(Integer lifetime) - { + public Notification withLifetime(Integer lifetime) { this.lifetime = lifetime; return this; } - public NotificationModel getModel() - { + public NotificationModel getModel() { return model; } - public void setModel(NotificationModel model) - { + public void setModel(NotificationModel model) { this.model = model; } - public Notification withModel(NotificationModel model) - { + public Notification withModel(NotificationModel model) { this.model = model; return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Notification [id="); builder.append(id); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationModel.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationModel.java new file mode 100644 index 000000000..1be01be5e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationModel.java @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import java.util.List; + +/** + * Pojo for notification model. + * + * @author Gregory Moyer - Initial contribution + */ +public class NotificationModel { + private Integer cycles; + private List frames; + private Sound sound; + + public Integer getCycles() { + return cycles; + } + + public void setCycles(Integer cycles) { + this.cycles = cycles; + } + + public NotificationModel withCycles(Integer cycles) { + this.cycles = cycles; + return this; + } + + public List getFrames() { + return frames; + } + + public void setFrames(List frames) { + this.frames = frames; + } + + public NotificationModel withFrames(List frames) { + this.frames = frames; + return this; + } + + public Sound getSound() { + return sound; + } + + public void setSound(Sound sound) { + this.sound = sound; + } + + public NotificationModel withSound(Sound sound) { + this.sound = sound; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("NotificationModel [cycles="); + builder.append(cycles); + builder.append(", frames="); + builder.append(frames); + builder.append(", sound="); + builder.append(sound); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationResult.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationResult.java new file mode 100644 index 000000000..4b8dda00d --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/NotificationResult.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for notification result. + * + * @author Gregory Moyer - Initial contribution + */ +public class NotificationResult { + private Success success; + + public Success getSuccess() { + return success; + } + + public void setSuccess(Success success) { + this.success = success; + } + + public NotificationResult withSuccess(Success success) { + this.success = success; + return this; + } + + public static class Success { + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Success withId(String id) { + this.id = id; + return this; + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Parameter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Parameter.java new file mode 100644 index 000000000..6723d2128 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Parameter.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for parameter. + * + * @author Gregory Moyer - Initial contribution + */ +public abstract class Parameter { + private String name; + private Boolean required; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Parameter withName(String name) { + setName(name); + return this; + } + + public Boolean getRequired() { + return required; + } + + public void setRequired(Boolean required) { + this.required = required; + } + + public Parameter withRequired(Boolean required) { + setRequired(required); + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Screensaver.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Screensaver.java new file mode 100644 index 000000000..0a7cd6265 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Screensaver.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for screensaver. + * + * @author Gregory Moyer - Initial contribution + */ +public class Screensaver { + private Boolean enabled; + private Modes modes; + private String widget; + + public Boolean isEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public Screensaver withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + public Modes getModes() { + return modes; + } + + public void setModes(Modes modes) { + this.modes = modes; + } + + public Screensaver withModes(Modes modes) { + this.modes = modes; + return this; + } + + public String getWidget() { + return widget; + } + + public void setWidget(String widget) { + this.widget = widget; + } + + public Screensaver withWidget(String widget) { + this.widget = widget; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Screensaver [enabled="); + builder.append(enabled); + builder.append(", modes="); + builder.append(modes); + builder.append(", widget="); + builder.append(widget); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Sound.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Sound.java new file mode 100644 index 000000000..91b62223b --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Sound.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for sound. + * + * @author Gregory Moyer - Initial contribution + */ +public class Sound { + private String category; + private String id; + private Integer repeat; + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public Sound withCategory(String category) { + this.category = category; + return this; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Sound withId(String id) { + this.id = id; + return this; + } + + public Integer getRepeat() { + return repeat; + } + + public void setRepeat(Integer repeat) { + this.repeat = repeat; + } + + public Sound withRepeat(Integer repeat) { + this.repeat = repeat; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("Sound [category="); + builder.append(category); + builder.append(", id="); + builder.append(id); + builder.append(", repeat="); + builder.append(repeat); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/StringParameter.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/StringParameter.java new file mode 100644 index 000000000..81ad6e1eb --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/StringParameter.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for stringparameter. + * + * @author Gregory Moyer - Initial contribution + */ +public class StringParameter extends Parameter { + private String format; + private String value; + + @Override + public StringParameter withName(String name) { + super.withName(name); + return this; + } + + @Override + public StringParameter withRequired(Boolean required) { + super.withRequired(required); + return this; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public StringParameter withFormat(String format) { + setFormat(format); + return this; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public StringParameter withValue(String value) { + setValue(value); + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("StringParameter [format="); + builder.append(format); + builder.append(", value="); + builder.append(value); + builder.append(", getName()="); + builder.append(getName()); + builder.append(", getRequired()="); + builder.append(getRequired()); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/TimeBased.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/TimeBased.java new file mode 100644 index 000000000..0c2599121 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/TimeBased.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for time based. + * + * @author Gregory Moyer - Initial contribution + */ +public class TimeBased { + private Boolean enabled; + + public Boolean isEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public TimeBased withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("TimeBased [enabled="); + builder.append(enabled); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateAction.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateAction.java new file mode 100644 index 000000000..6796490b1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateAction.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import java.util.SortedMap; + +/** + * Pojo for update action. + * + * @author Gregory Moyer - Initial contribution + */ +public class UpdateAction extends Action { + @Override + public UpdateAction withId(String id) { + super.setId(id); + return this; + } + + @Override + public UpdateAction withParameters(SortedMap parameters) { + super.setParameters(parameters); + return this; + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WhenDark.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WhenDark.java new file mode 100644 index 000000000..50258faf1 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WhenDark.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +/** + * Pojo for when dark. + * + * @author Gregory Moyer - Initial contribution + */ +public class WhenDark { + private Boolean enabled; + + public Boolean isEnabled() { + return enabled; + } + + public void setEnabled(Boolean enabled) { + this.enabled = enabled; + } + + public WhenDark withEnabled(Boolean enabled) { + this.enabled = enabled; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("WhenDark [enabled="); + builder.append(enabled); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Widget.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Widget.java similarity index 51% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Widget.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Widget.java index 41ae5190a..d1f3133fe 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Widget.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Widget.java @@ -1,100 +1,88 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import java.util.Map; import com.google.gson.JsonPrimitive; import com.google.gson.annotations.SerializedName; -public class Widget -{ +/** + * Pojo for widget. + * + * @author Gregory Moyer - Initial contribution + */ +public class Widget { private String id; @SerializedName("package") private String packageName; private Integer index; private Map settings; - public String getId() - { + public String getId() { return id; } - public void setId(String id) - { + public void setId(String id) { this.id = id; } - public Widget withId(String id) - { + public Widget withId(String id) { setId(id); return this; } - public String getPackageName() - { + public String getPackageName() { return packageName; } - public void setPackageName(String packageName) - { + public void setPackageName(String packageName) { this.packageName = packageName; } - public Widget withPackageName(String packageName) - { + public Widget withPackageName(String packageName) { setPackageName(packageName); return this; } - public Integer getIndex() - { + public Integer getIndex() { return index; } - public void setIndex(Integer index) - { + public void setIndex(Integer index) { this.index = index; } - public Widget withIndex(Integer index) - { + public Widget withIndex(Integer index) { setIndex(index); return this; } - public Map getSettings() - { + public Map getSettings() { return settings; } - public void setSettings(Map settings) - { + public void setSettings(Map settings) { this.settings = settings; } - public Widget withSettings(Map settings) - { + public Widget withSettings(Map settings) { setSettings(settings); return this; } @Override - public int hashCode() - { + public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((id == null) ? 0 : id.hashCode()); @@ -105,71 +93,50 @@ public class Widget } @Override - public boolean equals(Object obj) - { - if (this == obj) - { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (obj == null) - { + if (obj == null) { return false; } - if (getClass() != obj.getClass()) - { + if (getClass() != obj.getClass()) { return false; } - Widget other = (Widget)obj; - if (id == null) - { - if (other.id != null) - { + Widget other = (Widget) obj; + if (id == null) { + if (other.id != null) { return false; } - } - else if (!id.equals(other.id)) - { + } else if (!id.equals(other.id)) { return false; } - if (index == null) - { - if (other.index != null) - { + if (index == null) { + if (other.index != null) { return false; } - } - else if (!index.equals(other.index)) - { + } else if (!index.equals(other.index)) { return false; } - if (packageName == null) - { - if (other.packageName != null) - { + if (packageName == null) { + if (other.packageName != null) { return false; } - } - else if (!packageName.equals(other.packageName)) - { + } else if (!packageName.equals(other.packageName)) { return false; } - if (settings == null) - { - if (other.settings != null) - { + if (settings == null) { + if (other.settings != null) { return false; } - } - else if (!settings.equals(other.settings)) - { + } else if (!settings.equals(other.settings)) { return false; } return true; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Widget [id="); builder.append(id); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdates.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdates.java new file mode 100644 index 000000000..2aabc30b3 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdates.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import java.util.List; + +/** + * Pojo for widget updates. + * + * @author Gregory Moyer - Initial contribution + */ +public class WidgetUpdates { + private List frames; + + public List getFrames() { + return frames; + } + + public void setFrames(List frames) { + this.frames = frames; + } + + public WidgetUpdates withFrames(List frames) { + this.frames = frames; + return this; + } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("WidgetUpdates [frames="); + builder.append(frames); + builder.append("]"); + return builder.toString(); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Wifi.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Wifi.java similarity index 67% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Wifi.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Wifi.java index 542f603b2..616051993 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/model/Wifi.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/dto/Wifi.java @@ -1,22 +1,23 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -public class Wifi -{ +/** + * Pojo for wifi. + * + * @author Gregory Moyer - Initial contribution + */ +public class Wifi { private Boolean active; /* @@ -65,157 +66,129 @@ public class Wifi private Integer signalStrength; private Integer strength; - public Boolean isActive() - { + public Boolean isActive() { return active; } - public void setActive(Boolean active) - { + public void setActive(Boolean active) { this.active = active; } - public Wifi withActive(Boolean active) - { + public Wifi withActive(Boolean active) { this.active = active; return this; } - public String getMac() - { + public String getMac() { return mac == null ? address : mac; } - public void setMac(String mac) - { + public void setMac(String mac) { this.mac = mac; this.address = mac; } - public Wifi withMac(String mac) - { + public Wifi withMac(String mac) { setMac(mac); return this; } - public Boolean isAvailable() - { + public Boolean isAvailable() { return available; } - public void setAvailable(Boolean available) - { + public void setAvailable(Boolean available) { this.available = available; } - public Wifi withAvailable(Boolean available) - { + public Wifi withAvailable(Boolean available) { this.available = available; return this; } - public String getEncryption() - { + public String getEncryption() { return encryption; } - public void setEncryption(String encryption) - { + public void setEncryption(String encryption) { this.encryption = encryption; } - public Wifi withEncryption(String encryption) - { + public Wifi withEncryption(String encryption) { this.encryption = encryption; return this; } - public String getSsid() - { + public String getSsid() { return ssid == null ? essid : ssid; } - public void setSsid(String ssid) - { + public void setSsid(String ssid) { this.ssid = ssid; this.essid = ssid; } - public Wifi withSsid(String ssid) - { + public Wifi withSsid(String ssid) { setSsid(ssid); return this; } - public String getIp() - { + public String getIp() { return ip == null ? ipv4 : ip; } - public void setIp(String ip) - { + public void setIp(String ip) { this.ip = ip; this.ipv4 = ip; } - public Wifi withIp(String ip) - { + public Wifi withIp(String ip) { setIp(ip); return this; } - public String getMode() - { + public String getMode() { return mode; } - public void setMode(String mode) - { + public void setMode(String mode) { this.mode = mode; } - public Wifi withMode(String mode) - { + public Wifi withMode(String mode) { this.mode = mode; return this; } - public String getNetmask() - { + public String getNetmask() { return netmask; } - public void setNetmask(String netmask) - { + public void setNetmask(String netmask) { this.netmask = netmask; } - public Wifi withNetmask(String netmask) - { + public Wifi withNetmask(String netmask) { this.netmask = netmask; return this; } - public Integer getSignalStrength() - { + public Integer getSignalStrength() { return signalStrength == null ? strength : signalStrength; } - public void setSignalStrength(Integer signalStrength) - { + public void setSignalStrength(Integer signalStrength) { this.signalStrength = signalStrength; this.strength = signalStrength; } - public Wifi withSignalStrength(Integer signalStrength) - { + public Wifi withSignalStrength(Integer signalStrength) { setSignalStrength(signalStrength); return this; } @Override - public String toString() - { + public String toString() { StringBuilder builder = new StringBuilder(); builder.append("Wifi [active="); builder.append(active); diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImpl.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImpl.java similarity index 71% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImpl.java rename to bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImpl.java index 5aea72fe6..ff5ad982b 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/java/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImpl.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImpl.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.impl; +package org.openhab.binding.lametrictime.internal.api.local.impl; import java.io.BufferedReader; import java.io.InputStream; @@ -26,7 +23,6 @@ import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.util.List; import java.util.SortedMap; -import java.util.logging.Logger; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; @@ -38,42 +34,55 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; -import org.openhab.binding.lametrictime.api.authentication.HttpAuthenticationFeature; -import org.openhab.binding.lametrictime.api.cloud.impl.LaMetricTimeCloudImpl; -import org.openhab.binding.lametrictime.api.common.impl.AbstractClient; -import org.openhab.binding.lametrictime.api.filter.LoggingFilter; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; -import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException; -import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal; -import org.openhab.binding.lametrictime.api.local.LocalConfiguration; -import org.openhab.binding.lametrictime.api.local.NotificationCreationException; -import org.openhab.binding.lametrictime.api.local.NotificationNotFoundException; -import org.openhab.binding.lametrictime.api.local.UpdateException; -import org.openhab.binding.lametrictime.api.local.model.Api; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.AudioUpdateResult; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.BluetoothUpdateResult; -import org.openhab.binding.lametrictime.api.local.model.Device; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.DisplayUpdateResult; -import org.openhab.binding.lametrictime.api.local.model.Failure; -import org.openhab.binding.lametrictime.api.local.model.Notification; -import org.openhab.binding.lametrictime.api.local.model.NotificationResult; -import org.openhab.binding.lametrictime.api.local.model.UpdateAction; -import org.openhab.binding.lametrictime.api.local.model.WidgetUpdates; -import org.openhab.binding.lametrictime.api.local.model.Wifi; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lametrictime.internal.GsonProvider; +import org.openhab.binding.lametrictime.internal.api.authentication.HttpAuthenticationFeature; +import org.openhab.binding.lametrictime.internal.api.cloud.impl.LaMetricTimeCloudImpl; +import org.openhab.binding.lametrictime.internal.api.common.impl.AbstractClient; +import org.openhab.binding.lametrictime.internal.api.filter.LoggingFilter; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.LaMetricTimeLocal; +import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration; +import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException; +import org.openhab.binding.lametrictime.internal.api.local.NotificationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.UpdateException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Api; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.AudioUpdateResult; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.BluetoothUpdateResult; +import org.openhab.binding.lametrictime.internal.api.local.dto.Device; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.DisplayUpdateResult; +import org.openhab.binding.lametrictime.internal.api.local.dto.Failure; +import org.openhab.binding.lametrictime.internal.api.local.dto.Notification; +import org.openhab.binding.lametrictime.internal.api.local.dto.NotificationResult; +import org.openhab.binding.lametrictime.internal.api.local.dto.UpdateAction; +import org.openhab.binding.lametrictime.internal.api.local.dto.WidgetUpdates; +import org.openhab.binding.lametrictime.internal.api.local.dto.Wifi; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.reflect.TypeToken; +/** + * Implementation class for LaMeticTimeLocal interface. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTimeLocal { + private final Logger logger = LoggerFactory.getLogger(LaMetricTimeLocalImpl.class); + private static final String HEADER_ACCESS_TOKEN = "X-Access-Token"; private final LocalConfiguration config; + @Nullable private volatile Api api; public LaMetricTimeLocalImpl(LocalConfiguration config) { @@ -87,22 +96,21 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim @Override public Api getApi() { - if (api == null) { + Api localApi = api; + if (localApi == null) { synchronized (this) { - if (api == null) { - api = getClient().target(config.getBaseUri()).request(MediaType.APPLICATION_JSON_TYPE) - .get(Api.class); + localApi = getClient().target(config.getBaseUri()).request(MediaType.APPLICATION_JSON_TYPE) + .get(Api.class); + // remove support for v2.0.0 which has several errors in returned endpoints + if ("2.0.0".equals(localApi.getApiVersion())) { + throw new IllegalStateException( + "API version 2.0.0 detected, but 2.1.0 or greater is required. Please upgrade LaMetric Time firmware to version 1.7.7 or later. See http://lametric.com/firmware for more information."); } + return localApi; } + } else { + return localApi; } - - // remove support for v2.0.0 which has several errors in returned endpoints - if ("2.0.0".equals(api.getApiVersion())) { - throw new IllegalStateException( - "API version 2.0.0 detected, but 2.1.0 or greater is required. Please upgrade LaMetric Time firmware to version 1.7.7 or later. See http://lametric.com/firmware for more information."); - } - - return api; } @Override @@ -112,7 +120,7 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim } @Override - public String createNotification(Notification notification) throws NotificationCreationException { + public String createNotification(@Nullable Notification notification) throws NotificationCreationException { Response response = getClient().target(getApi().getEndpoints().getNotificationsUrl()) .request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(notification)); @@ -141,7 +149,7 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim } @Override - public Notification getCurrentNotification() { + public @Nullable Notification getCurrentNotification() { Notification notification = getClient().target(getApi().getEndpoints().getCurrentNotificationUrl()) .request(MediaType.APPLICATION_JSON_TYPE).get(Notification.class); @@ -269,15 +277,20 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim } @Override - public Application getApplication(String packageName) throws ApplicationNotFoundException { - Response response = getClient().target(getApi().getEndpoints().getAppsGetUrl().replace("{:id}", packageName)) - .request(MediaType.APPLICATION_JSON_TYPE).get(); + public @Nullable Application getApplication(@Nullable String packageName) throws ApplicationNotFoundException { + if (packageName != null) { + Response response = getClient() + .target(getApi().getEndpoints().getAppsGetUrl().replace("{:id}", packageName)) + .request(MediaType.APPLICATION_JSON_TYPE).get(); - if (!Status.Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily())) { - throw new ApplicationNotFoundException(response.readEntity(Failure.class)); + if (!Status.Family.SUCCESSFUL.equals(response.getStatusInfo().getFamily())) { + throw new ApplicationNotFoundException(response.readEntity(Failure.class)); + } + + return response.readEntity(Application.class); + } else { + return null; } - - return response.readEntity(Application.class); } @Override @@ -306,7 +319,8 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim } @Override - public void doAction(String packageName, String widgetId, UpdateAction action) throws ApplicationActionException { + public void doAction(String packageName, String widgetId, @Nullable UpdateAction action) + throws ApplicationActionException { Response response = getClient().target(getApi().getEndpoints().getAppsActionUrl().replace("{:id}", packageName) .replace("{:widget_id}", widgetId)).request(MediaType.APPLICATION_JSON_TYPE).post(Entity.json(action)); @@ -340,13 +354,13 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim SSLContext sslcontext = SSLContext.getInstance("TLS"); sslcontext.init(null, new TrustManager[] { new X509TrustManager() { @Override - public void checkClientTrusted(X509Certificate[] arg0, String arg1) + public void checkClientTrusted(X509Certificate @Nullable [] arg0, @Nullable String arg1) throws CertificateException { // noop } @Override - public void checkServerTrusted(X509Certificate[] arg0, String arg1) + public void checkServerTrusted(X509Certificate @Nullable [] arg0, @Nullable String arg1) throws CertificateException { // noop } @@ -355,11 +369,10 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } - } }, new java.security.SecureRandom()); builder.sslContext(sslcontext); } catch (KeyManagementException | NoSuchAlgorithmException e) { - throw new RuntimeException("Failed to setup secure communication", e); + logger.error("Failed to setup secure communication", e); } } @@ -380,8 +393,8 @@ public class LaMetricTimeLocalImpl extends AbstractClient implements LaMetricTim // turn on logging if requested if (config.isLogging()) { - builder.register( - new LoggingFilter(Logger.getLogger(LaMetricTimeCloudImpl.class.getName()), config.getLogMax())); + builder.register(new LoggingFilter( + java.util.logging.Logger.getLogger(LaMetricTimeCloudImpl.class.getName()), config.getLogMax())); } // setup basic auth diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeAppConfiguration.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeAppConfiguration.java index a8632073f..ef26bb8a5 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeAppConfiguration.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeAppConfiguration.java @@ -12,18 +12,27 @@ */ package org.openhab.binding.lametrictime.internal.config; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + /** * Configuration class for LaMetric Time apps. * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class LaMetricTimeAppConfiguration { public static final String PACKAGE_NAME = "packageName"; public static final String WIDGET_ID = "widgetId"; public static final String ACCESS_TOKEN = "accessToken"; + @Nullable public String packageName; + + @Nullable public String widgetId; + + @Nullable public String accessToken; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeConfiguration.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeConfiguration.java index b47d140a4..d68b7cdab 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeConfiguration.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/config/LaMetricTimeConfiguration.java @@ -12,16 +12,23 @@ */ package org.openhab.binding.lametrictime.internal.config; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; + /** * Configuration class for LaMetric Time device. * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class LaMetricTimeConfiguration { public static final String HOST = "host"; public static final String API_KEY = "apiKey"; + @Nullable public String host; + + @Nullable public String apiKey; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeAppDiscoveryService.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeAppDiscoveryService.java index e5deaef18..9a078f1b9 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeAppDiscoveryService.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeAppDiscoveryService.java @@ -17,11 +17,12 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Widget; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants; import org.openhab.binding.lametrictime.internal.LaMetricTimeUtil; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.binding.lametrictime.internal.handler.LaMetricTimeAppHandler; import org.openhab.binding.lametrictime.internal.handler.LaMetricTimeHandler; @@ -43,6 +44,7 @@ import com.google.gson.JsonPrimitive; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class LaMetricTimeAppDiscoveryService extends AbstractDiscoveryService { private static final Map CORE_APP_THING_TYPE_UIDS = new HashMap<>(); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeDiscoveryParticipant.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeDiscoveryParticipant.java index 59405a5a3..a961051dc 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/discovery/LaMetricTimeDiscoveryParticipant.java @@ -20,6 +20,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.jupnp.model.meta.RemoteDevice; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultBuilder; @@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory; * @author Gregory Moyer - Initial contribution */ @Component +@NonNullByDefault public class LaMetricTimeDiscoveryParticipant implements UpnpDiscoveryParticipant { private Logger logger = LoggerFactory.getLogger(LaMetricTimeDiscoveryParticipant.class); @@ -47,7 +50,7 @@ public class LaMetricTimeDiscoveryParticipant implements UpnpDiscoveryParticipan } @Override - public DiscoveryResult createResult(RemoteDevice device) { + public @Nullable DiscoveryResult createResult(RemoteDevice device) { ThingUID uid = getThingUID(device); if (uid == null) { return null; @@ -67,7 +70,7 @@ public class LaMetricTimeDiscoveryParticipant implements UpnpDiscoveryParticipan } @Override - public ThingUID getThingUID(RemoteDevice device) { + public @Nullable ThingUID getThingUID(RemoteDevice device) { try { String manufacturer = device.getDetails().getManufacturerDetails().getManufacturer(); String modelName = device.getDetails().getModelDetails().getModelName(); diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/AbstractLaMetricTimeAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/AbstractLaMetricTimeAppHandler.java index ed4e8b980..594794356 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/AbstractLaMetricTimeAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/AbstractLaMetricTimeAppHandler.java @@ -14,11 +14,13 @@ package org.openhab.binding.lametrictime.internal.handler; import java.util.SortedMap; -import org.openhab.binding.lametrictime.api.LaMetricTime; -import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Widget; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lametrictime.internal.WidgetRef; +import org.openhab.binding.lametrictime.internal.api.LaMetricTime; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; @@ -39,10 +41,12 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public abstract class AbstractLaMetricTimeAppHandler extends BaseThingHandler implements LaMetricTimeAppHandler { private final Logger logger = LoggerFactory.getLogger(AbstractLaMetricTimeAppHandler.class); + @Nullable private Widget widget; public AbstractLaMetricTimeAppHandler(Thing thing) { @@ -78,7 +82,7 @@ public abstract class AbstractLaMetricTimeAppHandler extends BaseThingHandler im } } - private void updateWidget(ThingHandler handler) { + private void updateWidget(@Nullable ThingHandler handler) { if (!(handler instanceof LaMetricTimeHandler)) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Incorrect bridge thing found"); return; @@ -116,7 +120,7 @@ public abstract class AbstractLaMetricTimeAppHandler extends BaseThingHandler im ((LaMetricTimeHandler) getBridge().getHandler()).updateActiveApp(widgetId); } - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return config.packageName; } @@ -126,7 +130,7 @@ public abstract class AbstractLaMetricTimeAppHandler extends BaseThingHandler im } @Override - public Widget getWidget() { + public @Nullable Widget getWidget() { if (widget == null) { getBridge().getHandler().initialize(); } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/ClockAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/ClockAppHandler.java index 3868df123..c3621a119 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/ClockAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/ClockAppHandler.java @@ -16,8 +16,10 @@ import static org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConst import java.time.LocalTime; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.StringType; @@ -34,6 +36,7 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class ClockAppHandler extends AbstractLaMetricTimeAppHandler { private static final String PACKAGE_NAME = "com.lametric.clock"; @@ -72,7 +75,7 @@ public class ClockAppHandler extends AbstractLaMetricTimeAppHandler { } @Override - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return PACKAGE_NAME; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/CountdownAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/CountdownAppHandler.java index 8d30b45ea..4c53b9341 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/CountdownAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/CountdownAppHandler.java @@ -14,8 +14,10 @@ package org.openhab.binding.lametrictime.internal.handler; import static org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants.*; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; @@ -31,6 +33,7 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class CountdownAppHandler extends AbstractLaMetricTimeAppHandler { private static final String PACKAGE_NAME = "com.lametric.countdown"; @@ -71,7 +74,7 @@ public class CountdownAppHandler extends AbstractLaMetricTimeAppHandler { } @Override - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return PACKAGE_NAME; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeAppHandler.java index 64f905f02..d984e55b0 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeAppHandler.java @@ -12,13 +12,16 @@ */ package org.openhab.binding.lametrictime.internal.handler; -import org.openhab.binding.lametrictime.api.local.model.Widget; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; /** * The {@link LaMetricTimeAppHandler} provides a common contract for all app handlers available for the device. * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public interface LaMetricTimeAppHandler { /** @@ -26,5 +29,5 @@ public interface LaMetricTimeAppHandler { * * @return the {@link Widget} */ - public Widget getWidget(); + public @Nullable Widget getWidget(); } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeHandler.java index 94d92e4c0..26690b652 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/LaMetricTimeHandler.java @@ -25,24 +25,26 @@ import java.util.concurrent.TimeUnit; import javax.ws.rs.client.ClientBuilder; -import org.openhab.binding.lametrictime.api.Configuration; -import org.openhab.binding.lametrictime.api.LaMetricTime; -import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; -import org.openhab.binding.lametrictime.api.local.LaMetricTimeLocal; -import org.openhab.binding.lametrictime.api.local.NotificationCreationException; -import org.openhab.binding.lametrictime.api.local.UpdateException; -import org.openhab.binding.lametrictime.api.local.model.Application; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.Device; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.Widget; -import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants; import org.openhab.binding.lametrictime.internal.LaMetricTimeConfigStatusMessage; import org.openhab.binding.lametrictime.internal.LaMetricTimeUtil; import org.openhab.binding.lametrictime.internal.StateDescriptionOptionsProvider; import org.openhab.binding.lametrictime.internal.WidgetRef; +import org.openhab.binding.lametrictime.internal.api.Configuration; +import org.openhab.binding.lametrictime.internal.api.LaMetricTime; +import org.openhab.binding.lametrictime.internal.api.dto.enums.BrightnessMode; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException; +import org.openhab.binding.lametrictime.internal.api.local.LaMetricTimeLocal; +import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException; +import org.openhab.binding.lametrictime.internal.api.local.UpdateException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Application; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.Device; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.Widget; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeConfiguration; import org.openhab.core.config.core.status.ConfigStatusMessage; import org.openhab.core.library.types.OnOffType; @@ -68,6 +70,7 @@ import org.slf4j.LoggerFactory; * @author Gregory Moyer - Initial contribution * @author Kai Kreuzer - Improved status handling, introduced refresh job and app state update */ +@NonNullByDefault public class LaMetricTimeHandler extends ConfigStatusBridgeHandler { private static final long CONNECTION_CHECK_INTERVAL = 60; @@ -78,8 +81,10 @@ public class LaMetricTimeHandler extends ConfigStatusBridgeHandler { private final ClientBuilder clientBuilder; + @NonNullByDefault({}) private LaMetricTime clock; + @Nullable private ScheduledFuture connectionJob; public LaMetricTimeHandler(Bridge bridge, StateDescriptionOptionsProvider stateDescriptionProvider, @@ -87,10 +92,6 @@ public class LaMetricTimeHandler extends ConfigStatusBridgeHandler { super(bridge); this.clientBuilder = clientBuilder; this.stateDescriptionProvider = stateDescriptionProvider; - - if (stateDescriptionProvider == null) { - logger.warn("State description provider is null"); - } } @Override diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/RadioAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/RadioAppHandler.java index db81eb526..a34b5980e 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/RadioAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/RadioAppHandler.java @@ -14,8 +14,10 @@ package org.openhab.binding.lametrictime.internal.handler; import static org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants.CHANNEL_APP_CONTROL; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.library.types.NextPreviousType; import org.openhab.core.library.types.PlayPauseType; @@ -32,6 +34,7 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class RadioAppHandler extends AbstractLaMetricTimeAppHandler { private static final String PACKAGE_NAME = "com.lametric.radio"; @@ -107,7 +110,7 @@ public class RadioAppHandler extends AbstractLaMetricTimeAppHandler { } @Override - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return PACKAGE_NAME; } } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/StopwatchAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/StopwatchAppHandler.java index c926f6b26..29519c903 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/StopwatchAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/StopwatchAppHandler.java @@ -14,8 +14,10 @@ package org.openhab.binding.lametrictime.internal.handler; import static org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants.CHANNEL_APP_COMMAND; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; @@ -31,6 +33,7 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class StopwatchAppHandler extends AbstractLaMetricTimeAppHandler { private static final String PACKAGE_NAME = "com.lametric.stopwatch"; @@ -65,7 +68,7 @@ public class StopwatchAppHandler extends AbstractLaMetricTimeAppHandler { } @Override - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return PACKAGE_NAME; } diff --git a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/WeatherAppHandler.java b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/WeatherAppHandler.java index e8564004a..360a536ef 100644 --- a/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/WeatherAppHandler.java +++ b/bundles/org.openhab.binding.lametrictime/src/main/java/org/openhab/binding/lametrictime/internal/handler/WeatherAppHandler.java @@ -14,8 +14,10 @@ package org.openhab.binding.lametrictime.internal.handler; import static org.openhab.binding.lametrictime.internal.LaMetricTimeBindingConstants.CHANNEL_APP_COMMAND; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.model.CoreApps; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; import org.openhab.binding.lametrictime.internal.config.LaMetricTimeAppConfiguration; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; @@ -31,6 +33,7 @@ import org.slf4j.LoggerFactory; * * @author Gregory Moyer - Initial contribution */ +@NonNullByDefault public class WeatherAppHandler extends AbstractLaMetricTimeAppHandler { private static final String PACKAGE_NAME = "com.lametric.weather"; @@ -63,7 +66,7 @@ public class WeatherAppHandler extends AbstractLaMetricTimeAppHandler { } @Override - protected String getPackageName(LaMetricTimeAppConfiguration config) { + protected @Nullable String getPackageName(LaMetricTimeAppConfiguration config) { return PACKAGE_NAME; } diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllIntegrationTestsSuite.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllIntegrationTestsSuite.java new file mode 100644 index 000000000..544da37a7 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllIntegrationTestsSuite.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +/** + * Integration test suit. + * + * @author Gregory Moyer - Initial contribution + */ +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({ "**/*IT.class" }) +@NonNullByDefault +public class AllIntegrationTestsSuite { + // Execute all integration tests +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllUnitTestsSuite.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllUnitTestsSuite.java new file mode 100644 index 000000000..35ada1a7c --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/AllUnitTestsSuite.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.runner.RunWith; + +import com.googlecode.junittoolbox.SuiteClasses; +import com.googlecode.junittoolbox.WildcardPatternSuite; + +/** + * Unit test suit. + * + * @author Gregory Moyer - Initial contribution + */ +@RunWith(WildcardPatternSuite.class) +@SuiteClasses({ "**/*Test.class" }) +@NonNullByDefault +public class AllUnitTestsSuite { + // Execute all unit tests +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessModeTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessModeTest.java new file mode 100644 index 000000000..09717a869 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/BrightnessModeTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * brightness mode test. + * + * @author Gregory Moyer - Initial contribution + */ +public class BrightnessModeTest { + @Test + public void testConversion() { + for (BrightnessMode value : BrightnessMode.values()) { + assertEquals(value, BrightnessMode.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(BrightnessMode.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(BrightnessMode.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayTypeTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayTypeTest.java new file mode 100644 index 000000000..34bd78a80 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/DisplayTypeTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * display type test. + * + * @author Gregory Moyer - Initial contribution + */ +public class DisplayTypeTest { + @Test + public void testConversion() { + for (DisplayType value : DisplayType.values()) { + assertEquals(value, DisplayType.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(DisplayType.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(DisplayType.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconTypeTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconTypeTest.java new file mode 100644 index 000000000..771e7ac6c --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IconTypeTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * icon type test. + * + * @author Gregory Moyer - Initial contribution + */ +public class IconTypeTest { + @Test + public void testConversion() { + for (IconType value : IconType.values()) { + assertEquals(value, IconType.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(IconType.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(IconType.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpModeTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpModeTest.java new file mode 100644 index 000000000..77e01bcf7 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/IpModeTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * ip mode test. + * + * @author Gregory Moyer - Initial contribution + */ +public class IpModeTest { + @Test + public void testConversion() { + for (IpMode value : IpMode.values()) { + assertEquals(value, IpMode.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(IpMode.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(IpMode.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/PriorityTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/PriorityTest.java new file mode 100644 index 000000000..c57428245 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/PriorityTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * priority test. + * + * @author Gregory Moyer - Initial contribution + */ +public class PriorityTest { + @Test + public void testConversion() { + for (Priority value : Priority.values()) { + assertEquals(value, Priority.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(Priority.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(Priority.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategoryTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategoryTest.java new file mode 100644 index 000000000..36b76e658 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundCategoryTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * sound category test. + * + * @author Gregory Moyer - Initial contribution + */ +public class SoundCategoryTest { + @Test + public void testConversion() { + for (SoundCategory value : SoundCategory.values()) { + assertEquals(value, SoundCategory.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(SoundCategory.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(SoundCategory.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundTest.java new file mode 100644 index 000000000..b52a91488 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/SoundTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * sound test. + * + * @author Gregory Moyer - Initial contribution + */ +public class SoundTest { + @Test + public void testConversion() { + for (Sound value : Sound.values()) { + assertEquals(value, Sound.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(Sound.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(Sound.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryptionTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryptionTest.java new file mode 100644 index 000000000..c936e3b43 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/dto/enums/WifiEncryptionTest.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.dto.enums; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +/** + * wifi encryption test. + * + * @author Gregory Moyer - Initial contribution + */ +public class WifiEncryptionTest { + @Test + public void testConversion() { + for (WifiEncryption value : WifiEncryption.values()) { + assertEquals(value, WifiEncryption.toEnum(value.toRaw())); + } + } + + @Test + public void testInvalidRawValue() { + assertNull(WifiEncryption.toEnum("invalid raw value")); + } + + @Test + public void testNullRawValue() { + assertNull(WifiEncryption.toEnum(null)); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/impl/FileIconTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/impl/FileIconTest.java new file mode 100644 index 000000000..3f1e25be6 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/impl/FileIconTest.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.impl; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.junit.jupiter.api.Test; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; + +/** + * file icon test. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class FileIconTest extends AbstractTest { + @Test + public void testLocalPathGif() { + FileIcon icon = new FileIcon(getTestDataPath("smile.gif")); + assertEquals( + "data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7", + icon.toRaw()); + } + + @Test + public void testLocalPathPng() { + FileIcon icon = new FileIcon(getTestDataPath("info.png")); + assertEquals( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=", + icon.toRaw()); + } + + @Test + public void testLocalFileGif() { + FileIcon icon = new FileIcon(getTestDataFile("smile.gif")); + assertEquals( + "data:image/gif;base64,R0lGODlhCAAIAPEAAPz+BPz+/AAAAAAAACH5BAkKAAIAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAACAAIAAACEZSAYJfIElREIdaGs3PPNFMAACH5BAkKAAIALAAAAAAIAAgAAAIRlIBgl8gSVEQh1oazU4szJxQAIfkECTIAAgAsAAAAAAgACAAAAhKUgGCXyBJURCHWhlU7fCmzCQUAIfkECRQAAgAsAAAAAAgACAAAAhGUgGCXyBIaClFa1Y5eymRRAAAh+QQJMgACACwAAAAACAAIAAACEpSAYJfIElREIdaGVTt8KbMJBQA7", + icon.toRaw()); + } + + @Test + public void testLocalFilePng() { + FileIcon icon = new FileIcon(getTestDataFile("info.png")); + assertEquals( + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAL0lEQVQYlWN0NPv3nwEPYIEx9p1kRJFwMofoY0IXQGczMRAAVFSA7EhkNiMhbwIAA/sN+bH1CpgAAAAASUVORK5CYII=", + icon.toRaw()); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ActionTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ActionTest.java similarity index 56% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ActionTest.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ActionTest.java index a8c71a2e8..d4c1701ef 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ActionTest.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ActionTest.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import static org.junit.jupiter.api.Assertions.*; @@ -24,25 +21,27 @@ import java.util.TreeMap; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; import com.google.gson.Gson; -public class ActionTest extends AbstractTest -{ +/** + * action test. + * + * @author Gregory Moyer - Initial contribution + */ +public class ActionTest extends AbstractTest { private static Gson gson; @BeforeAll - public static void setUpBeforeClass() - { + public static void setUpBeforeClass() { gson = GsonGenerator.create(true); } @Test @SuppressWarnings("serial") - public void testSerialize() throws Exception - { + public void testSerialize() throws Exception { // @formatter:off Action action = new Action().withParameters(new TreeMap(){{put("enabled", new BooleanParameter()); put("time", new StringParameter());}}); @@ -51,10 +50,8 @@ public class ActionTest extends AbstractTest } @Test - public void testDeserialize() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("action.json"))) - { + public void testDeserialize() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("action.json"))) { Action action = gson.fromJson(reader, Action.class); SortedMap parameters = action.getParameters(); assertNotNull(parameters); diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ApplicationTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ApplicationTest.java similarity index 63% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ApplicationTest.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ApplicationTest.java index a450205d4..617ad9a4c 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/ApplicationTest.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/ApplicationTest.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import static org.junit.jupiter.api.Assertions.*; @@ -24,30 +21,30 @@ import java.util.TreeMap; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; import com.google.gson.Gson; -public class ApplicationTest extends AbstractTest -{ +/** + * application test. + * + * @author Gregory Moyer - Initial contribution + */ +public class ApplicationTest extends AbstractTest { private static Gson gson; @BeforeAll - public static void setUpBeforeClass() - { + public static void setUpBeforeClass() { gson = GsonGenerator.create(true); } @Test @SuppressWarnings("serial") - public void testSerializeAllFields() throws Exception - { - Application app = new Application().withPackageName("com.lametric.radio") - .withVendor("LaMetric") - .withVersion("1.0.10") - .withVersionCode("22") - // @formatter:off + public void testSerializeAllFields() throws Exception { + Application app = new Application().withPackageName("com.lametric.radio").withVendor("LaMetric") + .withVersion("1.0.10").withVersionCode("22") + // @formatter:off .withWidgets(new TreeMap(){{put("589ed1b3fcdaa5180bf4848e55ba8061", new Widget());}}) .withActions(new TreeMap(){{put("radio.next", new Action()); put("radio.play", new Action()); @@ -58,20 +55,15 @@ public class ApplicationTest extends AbstractTest } @Test - public void testSerializeNullLists() throws Exception - { - Application app = new Application().withPackageName("com.lametric.radio") - .withVendor("LaMetric") - .withVersion("1.0.10") - .withVersionCode("22"); + public void testSerializeNullLists() throws Exception { + Application app = new Application().withPackageName("com.lametric.radio").withVendor("LaMetric") + .withVersion("1.0.10").withVersionCode("22"); assertEquals(readJson("application-null-maps.json"), gson.toJson(app)); } @Test - public void testDeserializeAllFields() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("application-all.json"))) - { + public void testDeserializeAllFields() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("application-all.json"))) { Application app = gson.fromJson(reader, Application.class); assertEquals("com.lametric.radio", app.getPackageName()); assertEquals("LaMetric", app.getVendor()); @@ -96,10 +88,8 @@ public class ApplicationTest extends AbstractTest } @Test - public void testDeserializeNullLists() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("application-null-maps.json"))) - { + public void testDeserializeNullLists() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("application-null-maps.json"))) { Application app = gson.fromJson(reader, Application.class); assertEquals("com.lametric.radio", app.getPackageName()); assertEquals("LaMetric", app.getVendor()); diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioTest.java new file mode 100644 index 000000000..2ff6e3476 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/AudioTest.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.FileReader; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; + +import com.google.gson.Gson; + +/** + * audio test. + * + * @author Gregory Moyer - Initial contribution + */ +public class AudioTest extends AbstractTest { + private static Gson gson; + + @BeforeAll + public static void setUpBeforeClass() { + gson = GsonGenerator.create(true); + } + + @Test + public void testSerializeAllFields() throws Exception { + Audio audio = new Audio().withVolume(42); + assertEquals(readJson("audio.json"), gson.toJson(audio)); + } + + @Test + public void testDeserializeAllFields() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("audio.json"))) { + Audio audio = gson.fromJson(reader, Audio.class); + assertEquals(Integer.valueOf(42), audio.getVolume()); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothTest.java new file mode 100644 index 000000000..1fbae8e4e --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/BluetoothTest.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.FileReader; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; + +import com.google.gson.Gson; + +/** + * bluetooth test. + * + * @author Gregory Moyer - Initial contribution + */ +public class BluetoothTest extends AbstractTest { + private static Gson gson; + + @BeforeAll + public static void setUpBeforeClass() { + gson = GsonGenerator.create(true); + } + + @Test + public void testSerializeAllFields() throws Exception { + Bluetooth bluetooth = new Bluetooth().withActive(false).withAvailable(true).withDiscoverable(false) + .withMac("AA:AA:AA:AA:AA:AA").withName("LM9999").withPairable(true); + assertEquals(readJson("bluetooth-mac-address.json"), gson.toJson(bluetooth)); + } + + @Test + public void testDeserializeMac() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("bluetooth-mac.json"))) { + Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class); + assertEquals(false, bluetooth.isActive()); + assertEquals(true, bluetooth.isAvailable()); + assertEquals(false, bluetooth.isDiscoverable()); + assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac()); + assertEquals("LM9999", bluetooth.getName()); + assertEquals(true, bluetooth.isPairable()); + } + } + + @Test + public void testDeserializeAddress() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("bluetooth-address.json"))) { + Bluetooth bluetooth = gson.fromJson(reader, Bluetooth.class); + assertEquals(false, bluetooth.isActive()); + assertEquals(true, bluetooth.isAvailable()); + assertEquals(false, bluetooth.isDiscoverable()); + assertEquals("AA:AA:AA:AA:AA:AA", bluetooth.getMac()); + assertEquals("LM9999", bluetooth.getName()); + assertEquals(true, bluetooth.isPairable()); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/FrameTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/FrameTest.java similarity index 54% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/FrameTest.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/FrameTest.java index 7cebb0323..e04f6d726 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/FrameTest.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/FrameTest.java @@ -1,68 +1,63 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.FileReader; import java.util.Arrays; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; import com.google.gson.Gson; -public class FrameTest extends AbstractTest -{ +/** + * frame test. + * + * @author Gregory Moyer - Initial contribution + */ +public class FrameTest extends AbstractTest { private static Gson gson; @BeforeAll - public static void setUpBeforeClass() - { + public static void setUpBeforeClass() { gson = GsonGenerator.create(true); } @Test - public void testSerializeSimple() throws Exception - { + public void testSerializeSimple() throws Exception { Frame frame = new Frame().withIcon("i87").withText("Hello world!"); assertEquals(readJson("frame-simple.json"), gson.toJson(frame)); } @Test - public void testSerializeGoal() throws Exception - { + public void testSerializeGoal() throws Exception { Frame frame = new Frame().withIcon("i120").withGoalData(new GoalData()); assertEquals(readJson("frame-goal.json"), gson.toJson(frame)); } @Test - public void testSerializeChart() throws Exception - { + public void testSerializeChart() throws Exception { Frame frame = new Frame().withChartData(Arrays.asList(1, 2, 3, 4, 5, 6, 7)); assertEquals(readJson("frame-chart.json"), gson.toJson(frame)); } @Test - public void testDeserializeSimple() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("frame-simple.json"))) - { + public void testDeserializeSimple() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("frame-simple.json"))) { Frame frame = gson.fromJson(reader, Frame.class); assertEquals("i87", frame.getIcon()); assertEquals("Hello world!", frame.getText()); @@ -72,10 +67,8 @@ public class FrameTest extends AbstractTest } @Test - public void testDeserializeGoal() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("frame-goal.json"))) - { + public void testDeserializeGoal() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("frame-goal.json"))) { Frame frame = gson.fromJson(reader, Frame.class); assertEquals("i120", frame.getIcon()); assertEquals(new GoalData(), frame.getGoalData()); @@ -83,10 +76,8 @@ public class FrameTest extends AbstractTest } @Test - public void testDeserializeChart() throws Exception - { - try (FileReader reader = new FileReader(getTestDataFile("frame-chart.json"))) - { + public void testDeserializeChart() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("frame-chart.json"))) { Frame frame = gson.fromJson(reader, Frame.class); assertEquals(Arrays.asList(1, 2, 3, 4, 5, 6, 7), frame.getChartData()); } diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalDataTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalDataTest.java new file mode 100644 index 000000000..e8a752206 --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/GoalDataTest.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.FileReader; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; + +import com.google.gson.Gson; + +/** + * goal data test. + * + * @author Gregory Moyer - Initial contribution + */ +public class GoalDataTest extends AbstractTest { + private static Gson gson; + + @BeforeAll + public static void setUpBeforeClass() { + gson = GsonGenerator.create(true); + } + + @Test + public void testSerializeSimple() throws Exception { + GoalData goalData = new GoalData().withStart(0).withEnd(100).withCurrent(50).withUnit("%"); + assertEquals(readJson("goal-data.json"), gson.toJson(goalData)); + } + + @Test + public void testDeserializeSimple() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("goal-data.json"))) { + GoalData goalData = gson.fromJson(reader, GoalData.class); + assertEquals(Integer.valueOf(0), goalData.getStart()); + assertEquals(Integer.valueOf(100), goalData.getEnd()); + assertEquals(Integer.valueOf(50), goalData.getCurrent()); + assertEquals("%", goalData.getUnit()); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/UpdateActionTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateActionTest.java similarity index 60% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/UpdateActionTest.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateActionTest.java index 03f283ca0..0cfde3247 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/UpdateActionTest.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/UpdateActionTest.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; import static org.junit.jupiter.api.Assertions.*; @@ -22,11 +19,16 @@ import java.util.TreeMap; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; import com.google.gson.Gson; +/** + * update action test. + * + * @author Gregory Moyer - Initial contribution + */ public class UpdateActionTest extends AbstractTest { private static Gson gson; diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetTest.java new file mode 100644 index 000000000..cd74fb1fb --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetTest.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.local.dto; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.io.FileReader; +import java.util.HashMap; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; + +import com.google.gson.Gson; +import com.google.gson.JsonPrimitive; + +/** + * widget test. + * + * @author Gregory Moyer - Initial contribution + */ +public class WidgetTest extends AbstractTest { + private static Gson gson; + + @BeforeAll + public static void setUpBeforeClass() { + gson = GsonGenerator.create(true); + } + + @Test + @SuppressWarnings("serial") + public void testSerialize() throws Exception { + Widget widget = new Widget().withPackageName("com.lametric.radio").withIndex(Integer.valueOf(-1)) + .withSettings(new HashMap() { + { + put("_title", new JsonPrimitive("Radio")); + } + }); + assertEquals(readJson("widget.json"), gson.toJson(widget)); + } + + @Test + @SuppressWarnings("serial") + public void testDeserialize() throws Exception { + try (FileReader reader = new FileReader(getTestDataFile("widget.json"))) { + Widget widget = gson.fromJson(reader, Widget.class); + assertEquals("com.lametric.radio", widget.getPackageName()); + assertEquals(Integer.valueOf(-1), widget.getIndex()); + assertEquals(new HashMap() { + { + put("_title", new JsonPrimitive("Radio")); + } + }, widget.getSettings()); + } + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetUpdatesTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdatesTest.java similarity index 62% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetUpdatesTest.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdatesTest.java index c59ea62d4..f797add6c 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/model/WidgetUpdatesTest.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/dto/WidgetUpdatesTest.java @@ -1,21 +1,18 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.model; +package org.openhab.binding.lametrictime.internal.api.local.dto; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.FileInputStream; import java.io.InputStreamReader; @@ -24,11 +21,16 @@ import java.util.Arrays; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator; -import org.openhab.binding.lametrictime.api.test.AbstractTest; +import org.openhab.binding.lametrictime.internal.api.common.impl.GsonGenerator; +import org.openhab.binding.lametrictime.internal.api.test.AbstractTest; import com.google.gson.Gson; +/** + * widget updates test. + * + * @author Gregory Moyer - Initial contribution + */ public class WidgetUpdatesTest extends AbstractTest { private static Gson gson; diff --git a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImplIT.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImplIT.java similarity index 78% rename from bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImplIT.java rename to bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImplIT.java index 5dfb0570d..92f3d66b5 100644 --- a/bundles/org.openhab.binding.lametrictime/src/3rdparty/test/org/openhab/binding/lametrictime/api/local/impl/LaMetricTimeLocalImplIT.java +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/local/impl/LaMetricTimeLocalImplIT.java @@ -1,19 +1,16 @@ /** - * Copyright 2017-2018 Gregory Moyer and contributors. + * Copyright (c) 2010-2023 Contributors to the openHAB project * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * See the NOTICE file(s) distributed with this work for additional + * information. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * SPDX-License-Identifier: EPL-2.0 */ -package org.openhab.binding.lametrictime.api.local.impl; +package org.openhab.binding.lametrictime.internal.api.local.impl; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -24,29 +21,31 @@ import java.io.InputStream; import java.util.Arrays; import java.util.Properties; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.openhab.binding.lametrictime.api.local.ApplicationActionException; -import org.openhab.binding.lametrictime.api.local.ApplicationActivationException; -import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException; -import org.openhab.binding.lametrictime.api.local.LocalConfiguration; -import org.openhab.binding.lametrictime.api.local.NotificationCreationException; -import org.openhab.binding.lametrictime.api.local.NotificationNotFoundException; -import org.openhab.binding.lametrictime.api.local.UpdateException; -import org.openhab.binding.lametrictime.api.local.model.Audio; -import org.openhab.binding.lametrictime.api.local.model.Bluetooth; -import org.openhab.binding.lametrictime.api.local.model.Display; -import org.openhab.binding.lametrictime.api.local.model.Frame; -import org.openhab.binding.lametrictime.api.local.model.GoalData; -import org.openhab.binding.lametrictime.api.local.model.Notification; -import org.openhab.binding.lametrictime.api.local.model.NotificationModel; -import org.openhab.binding.lametrictime.api.local.model.Sound; -import org.openhab.binding.lametrictime.api.model.CoreApps; -import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode; -import org.openhab.binding.lametrictime.api.model.enums.Priority; -import org.openhab.binding.lametrictime.api.model.enums.SoundCategory; -import org.openhab.binding.lametrictime.api.test.TestUtil; +import org.openhab.binding.lametrictime.internal.api.dto.CoreApps; +import org.openhab.binding.lametrictime.internal.api.dto.enums.BrightnessMode; +import org.openhab.binding.lametrictime.internal.api.dto.enums.Priority; +import org.openhab.binding.lametrictime.internal.api.dto.enums.SoundCategory; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActionException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationActivationException; +import org.openhab.binding.lametrictime.internal.api.local.ApplicationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.LocalConfiguration; +import org.openhab.binding.lametrictime.internal.api.local.NotificationCreationException; +import org.openhab.binding.lametrictime.internal.api.local.NotificationNotFoundException; +import org.openhab.binding.lametrictime.internal.api.local.UpdateException; +import org.openhab.binding.lametrictime.internal.api.local.dto.Audio; +import org.openhab.binding.lametrictime.internal.api.local.dto.Bluetooth; +import org.openhab.binding.lametrictime.internal.api.local.dto.Display; +import org.openhab.binding.lametrictime.internal.api.local.dto.Frame; +import org.openhab.binding.lametrictime.internal.api.local.dto.GoalData; +import org.openhab.binding.lametrictime.internal.api.local.dto.Notification; +import org.openhab.binding.lametrictime.internal.api.local.dto.NotificationModel; +import org.openhab.binding.lametrictime.internal.api.local.dto.Sound; +import org.openhab.binding.lametrictime.internal.api.test.TestUtil; /** *

@@ -63,12 +62,16 @@ import org.openhab.binding.lametrictime.api.test.TestUtil; * either execute the test via your IDE or run 'mvn -DskipITs=false * integration-test'. *

+ * + * @author Gregory Moyer - Initial contribution */ @Disabled +@NonNullByDefault public class LaMetricTimeLocalImplIT { private static final String PROP_HOST = "host"; private static final String PROP_API_KEY = "apiKey"; + @Nullable private static LaMetricTimeLocalImpl local; @BeforeAll @@ -225,8 +228,8 @@ public class LaMetricTimeLocalImplIT { local.getNotifications().stream().forEach(n -> { try { local.deleteNotification(n.getId()); - } catch (Exception e) { - e.printStackTrace(); + } catch (NotificationNotFoundException e) { + // ignore } }); @@ -245,7 +248,7 @@ public class LaMetricTimeLocalImplIT { return new Notification().withPriority(Priority.CRITICAL.toRaw()).withModel(new NotificationModel() .withCycles(cycles) .withSound(new Sound().withCategory(SoundCategory.NOTIFICATIONS.toRaw()) - .withId(org.openhab.binding.lametrictime.api.model.enums.Sound.CAT.toRaw())) + .withId(org.openhab.binding.lametrictime.internal.api.dto.enums.Sound.CAT.toRaw())) .withFrames(Arrays.asList(new Frame().withText("CAT!").withIcon( "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAUklEQVQYlWNUVFBgYGBgYBC98uE/AxJ4rSPAyMDAwMCETRJZjAnGgOlAZote+fCfCV0nOmA0+yKAYTwygJuAzQoGBgYGRkUFBQZ0dyDzGQl5EwCTESNpFb6zEwAAAABJRU5ErkJggg==")))); } diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/AbstractTest.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/AbstractTest.java new file mode 100644 index 000000000..1ba9dcbde --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/AbstractTest.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.test; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * abstract test class. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public abstract class AbstractTest { + protected File getTestDataFile(String name) { + return getTestDataPath(name).toFile(); + } + + protected Path getTestDataPath(String name) { + return TestUtil.getTestDataPath(this.getClass(), name); + } + + protected String readJson(String jsonFileName) throws IOException { + return String.join("\n", Files.readAllLines(getTestDataPath(jsonFileName))); + } +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/TestUtil.java b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/TestUtil.java new file mode 100644 index 000000000..b290072ff --- /dev/null +++ b/bundles/org.openhab.binding.lametrictime/src/test/java/org/openhab/binding/lametrictime/internal/api/test/TestUtil.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.lametrictime.internal.api.test; + +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * Test utility class. + * + * @author Gregory Moyer - Initial contribution + */ +@NonNullByDefault +public class TestUtil { + private static final String RESOURCES_PATH = "src/test/resources/"; + + public static Path getTestDataPath(Class clazz, String name) { + String packageName = clazz.getPackage().getName(); + + List paths = new ArrayList<>(); + paths.addAll(Arrays.asList(packageName.split("\\."))); + paths.add(name); + + return Paths.get(RESOURCES_PATH, paths.toArray(new String[paths.size()])); + } + + // @formatter:off + private TestUtil() {} + // @formatter:on +} diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/README b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/README similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/README rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/README diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/info.png b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/info.png similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/info.png rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/info.png diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/smile.gif b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/smile.gif similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/impl/smile.gif rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/impl/smile.gif diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/action.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/action.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/action.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/action.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/application-all.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/application-all.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/application-all.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/application-all.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/application-null-maps.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/application-null-maps.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/application-null-maps.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/application-null-maps.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/audio.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/audio.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/audio.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/audio.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-address.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-address.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-address.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-address.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-mac-address.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-mac-address.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-mac-address.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-mac-address.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-mac.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-mac.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/bluetooth-mac.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/bluetooth-mac.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-chart.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-chart.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-chart.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-chart.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-goal.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-goal.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-goal.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-goal.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-simple.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-simple.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/frame-simple.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/frame-simple.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/goal-data.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/goal-data.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/goal-data.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/goal-data.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/update-action.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/update-action.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/update-action.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/update-action.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/widget-updates.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/widget-updates.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/widget-updates.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/widget-updates.json diff --git a/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/widget.json b/bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/widget.json similarity index 100% rename from bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/api/local/model/widget.json rename to bundles/org.openhab.binding.lametrictime/src/test/resources/org/openhab/binding/lametrictime/internal/api/local/dto/widget.json