From bd740469f15532a01f907cca541f211a8d3bd3c1 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Fri, 7 Jun 2024 10:39:48 +0200 Subject: [PATCH] refactor(scripting_api): move DirectoryPayloadFormat to its own file --- lib/src/core/scripting_api.dart | 1 + .../discovery/directory_payload_format.dart | 34 +++++++++++++++++++ lib/src/core/scripting_api/wot.dart | 30 +--------------- 3 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 lib/src/core/scripting_api/discovery/directory_payload_format.dart diff --git a/lib/src/core/scripting_api.dart b/lib/src/core/scripting_api.dart index 2092af3b..954de639 100644 --- a/lib/src/core/scripting_api.dart +++ b/lib/src/core/scripting_api.dart @@ -12,6 +12,7 @@ library scripting_api; export "scripting_api/consumed_thing.dart"; export "scripting_api/data_schema_value.dart"; +export "scripting_api/discovery/directory_payload_format.dart"; export "scripting_api/discovery/thing_discovery.dart"; export "scripting_api/discovery/thing_filter.dart"; export "scripting_api/exposed_thing.dart"; diff --git a/lib/src/core/scripting_api/discovery/directory_payload_format.dart b/lib/src/core/scripting_api/discovery/directory_payload_format.dart new file mode 100644 index 00000000..db892c1b --- /dev/null +++ b/lib/src/core/scripting_api/discovery/directory_payload_format.dart @@ -0,0 +1,34 @@ +// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. +// +// SPDX-License-Identifier: BSD-3-Clause + +/// Enumeration for specifying the value of the `format` query parameter when +/// using the `exploreDirectory` discovery method. +/// +/// See [section 7.3.2.1.5] of the [WoT Discovery] specification for more +/// information. +/// +/// [WoT Discovery]: https://www.w3.org/TR/2023/REC-wot-discovery-20231205 +/// [section 7.3.2.1.5]: https://www.w3.org/TR/2023/REC-wot-discovery-20231205/#exploration-directory-api-things-listing +enum DirectoryPayloadFormat { + /// Indicates that an array of Thing Descriptions should be returned. + /// + /// This is the default value. + array, + + /// Indicates that an collection of Thing Descriptions should be returned. + collection, + ; + + @override + String toString() { + switch (this) { + case array: + return "array"; + case collection: + return "collection"; + } + } +} diff --git a/lib/src/core/scripting_api/wot.dart b/lib/src/core/scripting_api/wot.dart index d586bc45..4d23d896 100644 --- a/lib/src/core/scripting_api/wot.dart +++ b/lib/src/core/scripting_api/wot.dart @@ -7,40 +7,12 @@ import "../definitions.dart"; import "consumed_thing.dart"; +import "discovery/directory_payload_format.dart"; import "discovery/thing_discovery.dart"; import "discovery/thing_filter.dart"; import "exposed_thing.dart"; import "types.dart"; -/// Enumeration for specifying the value of the `format` query parameter when -/// using the `exploreDirectory` discovery method. -/// -/// See [section 7.3.2.1.5] of the [WoT Discovery] specification for more -/// information. -/// -/// [WoT Discovery]: https://www.w3.org/TR/2023/REC-wot-discovery-20231205 -/// [section 7.3.2.1.5]: https://www.w3.org/TR/2023/REC-wot-discovery-20231205/#exploration-directory-api-things-listing -enum DirectoryPayloadFormat { - /// Indicates that an array of Thing Descriptions should be returned. - /// - /// This is the default value. - array, - - /// Indicates that an collection of Thing Descriptions should be returned. - collection, - ; - - @override - String toString() { - switch (this) { - case array: - return "array"; - case collection: - return "collection"; - } - } -} - /// Interface for a [WoT] runtime. /// /// See WoT Scripting API specification,