Skip to content

Commit 8dd4483

Browse files
authored
Clean up obsolete code after migration to openapi-generator (#1032)
* Clean up obsolete code after migration to openapi-generator * Delete obsolete data --------- Signed-off-by: Tim Mueller-Seydlitz <timbms@gmail.com>
1 parent a6498bc commit 8dd4483

13 files changed

Lines changed: 99 additions & 1570 deletions

File tree

OpenHABCore/Sources/OpenHABCore/Model/OpenHABCommandDescription.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,6 @@ public struct OpenHABCommandDescription: Sendable {
1919
}
2020
}
2121

22-
public extension OpenHABCommandDescription {
23-
struct CodingData: Decodable {
24-
let commandOptions: [OpenHABCommandOptions]?
25-
}
26-
}
27-
28-
extension OpenHABCommandDescription.CodingData {
29-
var openHABCommandDescription: OpenHABCommandDescription {
30-
OpenHABCommandDescription(commandOptions: commandOptions)
31-
}
32-
}
33-
3422
extension OpenHABCommandDescription {
3523
init?(_ commands: Components.Schemas.CommandDescription?) {
3624
if let commands {

OpenHABCore/Sources/OpenHABCore/Model/OpenHABItem.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,6 @@ public extension OpenHABItem {
124124
}
125125
}
126126

127-
public extension OpenHABItem {
128-
struct CodingData: Decodable {
129-
let type: String?
130-
let groupType: String?
131-
let name: String
132-
let link: String?
133-
let state: String?
134-
let label: String?
135-
let stateDescription: OpenHABStateDescription.CodingData?
136-
let commandDescription: OpenHABCommandDescription.CodingData?
137-
let members: [OpenHABItem.CodingData]?
138-
let category: String?
139-
let options: [OpenHABOptions]?
140-
}
141-
}
142-
143-
public extension OpenHABItem.CodingData {
144-
var openHABItem: OpenHABItem {
145-
let mappedMembers = members?.map(\.openHABItem) ?? []
146-
// swiftlint:disable:next line_length
147-
return OpenHABItem(name: name, type: type ?? "", state: state, link: link ?? "", label: label, groupType: groupType, stateDescription: stateDescription?.openHABStateDescription, commandDescription: commandDescription?.openHABCommandDescription, members: mappedMembers, category: category, options: options)
148-
}
149-
}
150-
151127
extension OpenHABItem {
152128
init?(_ item: Components.Schemas.EnrichedItemDTO?) {
153129
// unitSymbol

OpenHABCore/Sources/OpenHABCore/Model/OpenHABPage.swift

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,6 @@ public extension OpenHABPage {
5959
}
6060
}
6161

62-
public extension OpenHABPage {
63-
struct CodingData: Decodable {
64-
private enum CodingKeys: String, CodingKey {
65-
case pageId = "id"
66-
case title
67-
case link
68-
case leaf
69-
case widgets
70-
case icon
71-
}
72-
73-
let pageId: String?
74-
let title: String?
75-
let link: String?
76-
let leaf: Bool?
77-
let widgets: [OpenHABWidget.CodingData]?
78-
let icon: String?
79-
}
80-
}
81-
82-
public extension OpenHABPage.CodingData {
83-
var openHABSitemapPage: OpenHABPage {
84-
let mappedWidgets = widgets?.map(\.openHABWidget) ?? []
85-
return OpenHABPage(pageId: pageId.orEmpty, title: title.orEmpty, link: link.orEmpty, leaf: leaf ?? false, widgets: mappedWidgets, icon: icon.orEmpty)
86-
}
87-
}
88-
8962
public extension OpenHABPage {
9063
convenience init?(_ page: Components.Schemas.PageDTO?) {
9164
if let page {

OpenHABCore/Sources/OpenHABCore/Model/OpenHABSitemapWidgetEvent.swift

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ public class OpenHABSitemapWidgetEvent {
4646

4747
convenience init?(_ event: Components.Schemas.SitemapWidgetEvent?) {
4848
guard let event else { return nil }
49-
// swiftlint:disable:next line_length
5049
self.init(sitemapName: event.sitemapName, pageId: event.pageId, widgetId: event.widgetId, label: event.label, labelSource: event.labelSource, icon: event.icon, reloadIcon: event.reloadIcon, labelcolor: event.labelcolor, valuecolor: event.valuecolor, iconcolor: event.iconcolor, visibility: event.visibility, state: event.state, enrichedItem: OpenHABItem(event.item), descriptionChanged: event.descriptionChanged)
5150
}
5251
}
@@ -56,51 +55,3 @@ extension OpenHABSitemapWidgetEvent: CustomStringConvertible {
5655
"\(widgetId ?? "") \(label ?? "") \(enrichedItem?.state ?? "")"
5756
}
5857
}
59-
60-
public extension OpenHABSitemapWidgetEvent {
61-
struct CodingData: Decodable, Hashable, Equatable {
62-
var sitemapName: String?
63-
var pageId: String?
64-
var widgetId: String?
65-
var label: String?
66-
var labelSource: String?
67-
var icon: String?
68-
var reloadIcon: Bool?
69-
var labelcolor: String?
70-
var valuecolor: String?
71-
var iconcolor: String?
72-
var visibility: Bool?
73-
// var state: String?
74-
var item: OpenHABItem.CodingData?
75-
var descriptionChanged: Bool?
76-
var link: String?
77-
78-
public static func == (lhs: OpenHABSitemapWidgetEvent.CodingData, rhs: OpenHABSitemapWidgetEvent.CodingData) -> Bool {
79-
lhs.widgetId == rhs.widgetId
80-
}
81-
82-
public func hash(into hasher: inout Hasher) {
83-
hasher.combine(widgetId)
84-
}
85-
}
86-
}
87-
88-
extension OpenHABSitemapWidgetEvent.CodingData {
89-
var openHABSitemapWidgetEvent: OpenHABSitemapWidgetEvent {
90-
OpenHABSitemapWidgetEvent(
91-
sitemapName: sitemapName,
92-
pageId: pageId,
93-
widgetId: widgetId,
94-
label: label,
95-
labelSource: labelSource,
96-
icon: icon,
97-
reloadIcon: reloadIcon,
98-
labelcolor: labelcolor,
99-
valuecolor: valuecolor,
100-
iconcolor: iconcolor,
101-
visibility: visibility,
102-
enrichedItem: item?.openHABItem,
103-
descriptionChanged: descriptionChanged
104-
)
105-
}
106-
}

OpenHABCore/Sources/OpenHABCore/Model/OpenHABStateDescription.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,6 @@ public struct OpenHABStateDescription: Sendable {
4343
}
4444
}
4545

46-
public extension OpenHABStateDescription {
47-
struct CodingData: Decodable {
48-
let minimum: Double?
49-
let maximum: Double?
50-
let step: Double?
51-
let readOnly: Bool?
52-
let options: [OpenHABOptions]?
53-
let pattern: String?
54-
}
55-
}
56-
57-
extension OpenHABStateDescription.CodingData {
58-
var openHABStateDescription: OpenHABStateDescription {
59-
OpenHABStateDescription(minimum: minimum, maximum: maximum, step: step, readOnly: readOnly, options: options, pattern: pattern)
60-
}
61-
}
62-
6346
extension OpenHABStateDescription {
6447
init?(_ state: Components.Schemas.StateDescription?) {
6548
if let state {

OpenHABCore/Sources/OpenHABCore/Model/OpenHABWidget.swift

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -346,84 +346,6 @@ public extension OpenHABWidget {
346346
}
347347
}
348348

349-
public extension OpenHABWidget {
350-
struct CodingData: Decodable {
351-
let widgetId: String
352-
let label: String
353-
let type: WidgetType
354-
let icon: String
355-
let url: String?
356-
let period: String?
357-
let minValue: Double?
358-
let maxValue: Double?
359-
let step: Double?
360-
let refresh: Int?
361-
let height: Double?
362-
let isLeaf: Bool?
363-
let iconcolor: String?
364-
let labelcolor: String?
365-
let valuecolor: String?
366-
let service: String?
367-
let state: String?
368-
let text: String?
369-
let legend: Bool?
370-
let inputHint: InputHint?
371-
let encoding: String?
372-
let groupType: String?
373-
let item: OpenHABItem.CodingData?
374-
let linkedPage: OpenHABPage.CodingData?
375-
let mappings: [OpenHABWidgetMapping]
376-
let widgets: [OpenHABWidget.CodingData]
377-
let visibility: Bool?
378-
let switchSupport: Bool?
379-
let forceAsItem: Bool?
380-
let unit: String?
381-
let pattern: String?
382-
let staticIcon: Bool?
383-
let labelSource: String?
384-
}
385-
}
386-
387-
public extension OpenHABWidget.CodingData {
388-
var openHABWidget: OpenHABWidget {
389-
let mappedWidgets = widgets.map(\.openHABWidget)
390-
return OpenHABWidget(
391-
widgetId: widgetId,
392-
label: label,
393-
icon: icon,
394-
type: type,
395-
url: url,
396-
period: period,
397-
minValue: minValue,
398-
maxValue: maxValue,
399-
step: step,
400-
refresh: refresh,
401-
height: height,
402-
isLeaf: isLeaf,
403-
iconColor: iconcolor,
404-
labelColor: labelcolor,
405-
valueColor: valuecolor,
406-
service: service,
407-
state: state,
408-
text: text,
409-
legend: legend,
410-
inputHint: inputHint,
411-
encoding: encoding,
412-
item: item?.openHABItem,
413-
linkedPage: linkedPage?.openHABSitemapPage,
414-
mappings: mappings,
415-
widgets: mappedWidgets,
416-
visibility: visibility,
417-
switchSupport: switchSupport,
418-
forceAsItem: forceAsItem,
419-
unit: unit,
420-
pattern: pattern,
421-
staticIcon: staticIcon,
422-
labelSource: labelSource
423-
)
424-
}
425-
}
426-
427349
// Recursive parsing of nested widget structure
428350
public extension [OpenHABWidget] {
429351
mutating func flatten(_ widgets: [Element]) {

OpenHABCore/Tests/OpenHABCoreTests/JSONData.swift

Lines changed: 0 additions & 471 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)