test_class.declarator: matcher
test_class.modifier: private
test_class.original_string: private MetadataSelectorMatcher matcher;
test_class.type: MetadataSelectorMatcher
test_class.var_name: matcher
test_class.declarator: configDescriptionRegistry
test_class.modifier: private @Mock
test_class.original_string: private @Mock ConfigDescriptionRegistry configDescriptionRegistry;
test_class.type: ConfigDescriptionRegistry
test_class.var_name: configDescriptionRegistry
test_class.declarator: metadataRegistry
test_class.modifier: private @Mock
test_class.original_string: private @Mock MetadataRegistry metadataRegistry;
test_class.type: MetadataRegistry
test_class.var_name: metadataRegistry
test_class.file: bundles/org.openhab.core.io.rest.core/src/test/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcherTest.java
test_class.identifier: MetadataSelectorMatcherTest
test_case.body: @Test
      public void nonConfigDescriptionSelectorShouldBeResult() {
          assertThat(matcher.filterNamespaces("magic, foo, bar", null), hasItems("magic", "foo", "bar"));
      }
test_case.class_method_signature: MetadataSelectorMatcherTest.nonConfigDescriptionSelectorShouldBeResult()
test_case.full_signature: @Test public void nonConfigDescriptionSelectorShouldBeResult()
test_case.identifier: nonConfigDescriptionSelectorShouldBeResult
test_case.invocations: assertThat filterNamespaces hasItems
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void nonConfigDescriptionSelectorShouldBeResult()
focal_class.declarator: METADATA_SCHEME = "metadata"
focal_class.modifier: private static final
focal_class.original_string: private static final String METADATA_SCHEME = "metadata";
focal_class.type: String
focal_class.var_name: METADATA_SCHEME
focal_class.declarator: METADATA_SCHEME_PREFIX = METADATA_SCHEME + ":"
focal_class.modifier: private static final
focal_class.original_string: private static final String METADATA_SCHEME_PREFIX = METADATA_SCHEME + ":";
focal_class.type: String
focal_class.var_name: METADATA_SCHEME_PREFIX
focal_class.declarator: metadataRegistry
focal_class.modifier: private final
focal_class.original_string: private final MetadataRegistry metadataRegistry;
focal_class.type: MetadataRegistry
focal_class.var_name: metadataRegistry
focal_class.declarator: configDescriptionRegistry
focal_class.modifier: private final
focal_class.original_string: private final ConfigDescriptionRegistry configDescriptionRegistry;
focal_class.type: ConfigDescriptionRegistry
focal_class.var_name: configDescriptionRegistry
focal_class.file: bundles/org.openhab.core.io.rest.core/src/main/java/org/openhab/core/io/rest/core/internal/item/MetadataSelectorMatcher.java
focal_class.identifier: MetadataSelectorMatcher
focal_class.class_method_signature: MetadataSelectorMatcher.MetadataSelectorMatcher(final @Reference MetadataRegistry metadataRegistry,
              final @Reference ConfigDescriptionRegistry configDescriptionRegistry)
focal_class.full_signature: @Activate public  MetadataSelectorMatcher(final @Reference MetadataRegistry metadataRegistry,
              final @Reference ConfigDescriptionRegistry configDescriptionRegistry)
focal_class.identifier: MetadataSelectorMatcher
focal_class.modifiers: @Activate public
focal_class.parameters: (final @Reference MetadataRegistry metadataRegistry,
              final @Reference ConfigDescriptionRegistry configDescriptionRegistry)
focal_class.signature:  MetadataSelectorMatcher(final @Reference MetadataRegistry metadataRegistry,
              final @Reference ConfigDescriptionRegistry configDescriptionRegistry)
focal_class.class_method_signature: MetadataSelectorMatcher.filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)
focal_class.full_signature: public Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)
focal_class.identifier: filterNamespaces
focal_class.modifiers: public
focal_class.parameters: (@Nullable String namespaceSelector, @Nullable Locale locale)
focal_class.return: Set<String>
focal_class.signature: Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)
focal_method.body: public Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale) {
          if (namespaceSelector == null || namespaceSelector.isEmpty()) {
              return Collections.emptySet();
          } else {
              Set<String> originalNamespaces = Arrays.stream(namespaceSelector.split(",")) //
                      .filter(n -> !metadataRegistry.isInternalNamespace(n)) //
                      .map(n -> n.trim()) //
                      .collect(Collectors.toSet());
  
              String namespacePattern = originalNamespaces.stream().collect(Collectors.joining("|"));
  
              Pattern pattern = Pattern.compile(METADATA_SCHEME_PREFIX + "(" + namespacePattern + ")$");
              Collection<ConfigDescription> configDescriptions = configDescriptionRegistry.getConfigDescriptions(locale);
  
              Set<String> configNamespaces = configDescriptions.stream()
                      .filter(cd -> METADATA_SCHEME.equals(cd.getUID().getScheme())).map(cd -> cd.getUID().toString())
                      .filter(pattern.asPredicate()).map(uri -> uri.substring(METADATA_SCHEME_PREFIX.length()))
                      .collect(toSet());
  
              // merge configDescription namespaces and namespaces from the namespace selector:
              Set<String> result = new HashSet<>(originalNamespaces);
              result.addAll(configNamespaces);
  
              // filter all name spaces which do not match the UID segment pattern (this will be the regex tokens):
              return result.stream().filter(namespace -> namespace.matches(AbstractUID.SEGMENT_PATTERN)).collect(toSet());
          }
      }
focal_method.class_method_signature: MetadataSelectorMatcher.filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)
focal_method.full_signature: public Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)
focal_method.identifier: filterNamespaces
focal_method.invocations: isEmpty emptySet collect map filter stream split isInternalNamespace trim toSet collect stream joining compile getConfigDescriptions collect map filter map filter stream equals getScheme getUID toString getUID asPredicate substring length toSet addAll collect filter stream matches toSet
focal_method.modifiers: public
focal_method.parameters: (@Nullable String namespaceSelector, @Nullable Locale locale)
focal_method.return: Set<String>
focal_method.signature: Set<String> filterNamespaces(@Nullable String namespaceSelector, @Nullable Locale locale)