Skip to content

Commit 8efa024

Browse files
authored
File format generator: do not change order of thing channels (#4636)
Keep original order of channels Signed-off-by: Laurent Garnier <[email protected]>
1 parent 3af47e9 commit 8efa024

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

bundles/org.openhab.core.thing/src/main/java/org/openhab/core/thing/fileconverter/AbstractThingFileGenerator.java

+2-18
Original file line numberDiff line numberDiff line change
@@ -174,32 +174,16 @@ private List<ConfigDescriptionParameter> getConfigDescriptionParameters(Channel
174174
* Get non default channels.
175175
* It includes extensible channels and channels with a non default configuration.
176176
*
177-
* Resulting channels are sorted in such a way that channels without channel type are after channels
178-
* with a channel type. Sort is done first on the channel type and then on the channel UID.
179-
*
180177
* @param thing the thing
181-
* @return the sorted list of channels
178+
* @return the list of channels
182179
*/
183180
protected List<Channel> getNonDefaultChannels(Thing thing) {
184181
ThingType thingType = thingTypeRegistry.getThingType(thing.getThingTypeUID());
185182
List<String> ids = thingType != null ? thingType.getExtensibleChannelTypeIds() : List.of();
186-
List<Channel> channels = thing
183+
return thing
187184
.getChannels().stream().filter(ch -> ch.getChannelTypeUID() == null
188185
|| ids.contains(ch.getChannelTypeUID().getId()) || channelWithNonDefaultConfig(ch))
189186
.collect(Collectors.toList());
190-
return channels.stream().sorted((ch1, ch2) -> {
191-
ChannelTypeUID typeUID1 = ch1.getChannelTypeUID();
192-
ChannelTypeUID typeUID2 = ch2.getChannelTypeUID();
193-
if (typeUID1 != null && typeUID2 == null) {
194-
return -1;
195-
} else if (typeUID1 == null && typeUID2 != null) {
196-
return 1;
197-
} else if (typeUID1 != null && typeUID2 != null && !typeUID1.equals(typeUID2)) {
198-
return typeUID1.getAsString().compareTo(typeUID2.getAsString());
199-
} else {
200-
return ch1.getUID().getAsString().compareTo(ch2.getUID().getAsString());
201-
}
202-
}).collect(Collectors.toList());
203187
}
204188

205189
private boolean channelWithNonDefaultConfig(Channel channel) {

0 commit comments

Comments
 (0)