@@ -18,21 +18,24 @@ public struct DictionaryEntry: Codable, JSONEncodable {
18
18
/// Invividual components of a compound word in the `compounds` dictionary.
19
19
public var decomposition : [ String ] ?
20
20
public var state : DictionaryEntryState ?
21
+ public var type : DictionaryEntryType ?
21
22
22
23
public init (
23
24
objectID: String ,
24
25
language: SearchSupportedLanguage ? = nil ,
25
26
word: String ? = nil ,
26
27
words: [ String ] ? = nil ,
27
28
decomposition: [ String ] ? = nil ,
28
- state: DictionaryEntryState ? = nil
29
+ state: DictionaryEntryState ? = nil ,
30
+ type: DictionaryEntryType ? = nil
29
31
) {
30
32
self . objectID = objectID
31
33
self . language = language
32
34
self . word = word
33
35
self . words = words
34
36
self . decomposition = decomposition
35
37
self . state = state
38
+ self . type = type
36
39
}
37
40
38
41
public enum CodingKeys : String , CodingKey , CaseIterable {
@@ -42,6 +45,7 @@ public struct DictionaryEntry: Codable, JSONEncodable {
42
45
case words
43
46
case decomposition
44
47
case state
48
+ case type
45
49
}
46
50
47
51
public var additionalProperties : [ String : AnyCodable ] = [ : ]
@@ -74,9 +78,11 @@ public struct DictionaryEntry: Codable, JSONEncodable {
74
78
75
79
self . state = dictionary [ " state " ] ? . value as? DictionaryEntryState
76
80
81
+ self . type = dictionary [ " type " ] ? . value as? DictionaryEntryType
82
+
77
83
for (key, value) in dictionary {
78
84
switch key {
79
- case " objectID " , " language " , " word " , " words " , " decomposition " , " state " :
85
+ case " objectID " , " language " , " word " , " words " , " decomposition " , " state " , " type " :
80
86
continue
81
87
default :
82
88
self . additionalProperties [ key] = value
@@ -94,6 +100,7 @@ public struct DictionaryEntry: Codable, JSONEncodable {
94
100
try container. encodeIfPresent ( self . words, forKey: . words)
95
101
try container. encodeIfPresent ( self . decomposition, forKey: . decomposition)
96
102
try container. encodeIfPresent ( self . state, forKey: . state)
103
+ try container. encodeIfPresent ( self . type, forKey: . type)
97
104
var additionalPropertiesContainer = encoder. container ( keyedBy: String . self)
98
105
try additionalPropertiesContainer. encodeMap ( self . additionalProperties)
99
106
}
@@ -109,13 +116,15 @@ public struct DictionaryEntry: Codable, JSONEncodable {
109
116
self . words = try container. decodeIfPresent ( [ String ] . self, forKey: . words)
110
117
self . decomposition = try container. decodeIfPresent ( [ String ] . self, forKey: . decomposition)
111
118
self . state = try container. decodeIfPresent ( DictionaryEntryState . self, forKey: . state)
119
+ self . type = try container. decodeIfPresent ( DictionaryEntryType . self, forKey: . type)
112
120
var nonAdditionalPropertyKeys = Set < String > ( )
113
121
nonAdditionalPropertyKeys. insert ( " objectID " )
114
122
nonAdditionalPropertyKeys. insert ( " language " )
115
123
nonAdditionalPropertyKeys. insert ( " word " )
116
124
nonAdditionalPropertyKeys. insert ( " words " )
117
125
nonAdditionalPropertyKeys. insert ( " decomposition " )
118
126
nonAdditionalPropertyKeys. insert ( " state " )
127
+ nonAdditionalPropertyKeys. insert ( " type " )
119
128
let additionalPropertiesContainer = try decoder. container ( keyedBy: String . self)
120
129
self . additionalProperties = try additionalPropertiesContainer. decodeMap (
121
130
AnyCodable . self,
@@ -131,7 +140,8 @@ extension DictionaryEntry: Equatable {
131
140
lhs. word == rhs. word &&
132
141
lhs. words == rhs. words &&
133
142
lhs. decomposition == rhs. decomposition &&
134
- lhs. state == rhs. state
143
+ lhs. state == rhs. state &&
144
+ lhs. type == rhs. type
135
145
&& lhs. additionalProperties == rhs. additionalProperties
136
146
}
137
147
}
@@ -144,6 +154,7 @@ extension DictionaryEntry: Hashable {
144
154
hasher. combine ( self . words? . hashValue)
145
155
hasher. combine ( self . decomposition? . hashValue)
146
156
hasher. combine ( self . state? . hashValue)
157
+ hasher. combine ( self . type? . hashValue)
147
158
hasher. combine ( self . additionalProperties. hashValue)
148
159
}
149
160
}
0 commit comments