Skip to content

Commit

Permalink
hack to get synonyms and description
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Tanagra <[email protected]>
  • Loading branch information
jimtng committed Apr 15, 2023
1 parent f06511e commit c030599
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/openhab/core/items/semantics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,18 @@ def label(locale = nil)
end

#
# REturns the tag's synonyms
# Returns the tag's synonyms
#
# @param [java.util.Locale] locale The locale that the label should be in, if available.
# When nil, the system's default locale is used.
#
# @return [Array<String>] The list of synonyms in the requested locale.
#
def synonyms(locale = nil)
return "" unless SemanticTags.respond_to?(:get_synonyms) # @deprecated OH3.4
unless SemanticTags.respond_to?(:get_synonyms) # @deprecated OH3.4
java_class.get_annotation(org.openhab.core.semantics.TagInfo.java_class).synonyms
.split(",").map(&:strip)
end

SemanticTags.get_synonyms(java_class, locale || java.util.Locale.default)
end
Expand All @@ -534,7 +537,9 @@ def synonyms(locale = nil)
# @return [String] The tag's description
#
def description(locale = nil)
return "" unless SemanticTags.respond_to?(:get_description) # @deprecated OH3.4
unless SemanticTags.respond_to?(:get_description) # @deprecated OH3.4
java_class.get_annotation(org.openhab.core.semantics.TagInfo.java_class).description
end

SemanticTags.get_description(java_class, locale || java.util.Locale.default)
end
Expand Down

0 comments on commit c030599

Please sign in to comment.