SemanticsServiceImpl implements SemanticsService { @Override public Set<Item> getItemsInLocation(Class<? extends Location> locationType) { Set<Item> items = new HashSet<>(); Set<Item> locationItems = itemRegistry.stream().filter(SemanticsPredicates.isA(locationType)) .collect(Collectors.toSet()); for (Item locationItem : locationItems) { if (locationItem instanceof GroupItem) { GroupItem gItem = (GroupItem) locationItem; items.addAll(gItem .getMembers(SemanticsPredicates.isA(Point.class).or(SemanticsPredicates.isA(Equipment.class)))); } } return items; } @Activate  SemanticsServiceImpl(final @Reference ItemRegistry itemRegistry,
            final @Reference MetadataRegistry metadataRegistry); @Override Set<Item> getItemsInLocation(Class<? extends Location> locationType); @SuppressWarnings({ "unchecked" }) @Override Set<Item> getItemsInLocation(String labelOrSynonym, Locale locale);  }
@Test public void testGetItemsInLocation() throws Exception { Set<Item> items = service.getItemsInLocation(Bathroom.class); assertTrue(items.contains(pointItem)); items = service.getItemsInLocation("Room", Locale.ENGLISH); assertTrue(items.contains(pointItem)); }
@Test public void testGetItemsInLocationByString() throws Exception { Set<Item> items = service.getItemsInLocation("joe's room", Locale.ENGLISH); assertTrue(items.contains(pointItem)); items = service.getItemsInLocation(LivingRoom.class); assertTrue(items.isEmpty()); }