SemanticTags { public static @Nullable Class<? extends Tag> getSemanticType(Item item) { Set<String> tags = item.getTags(); for (String tag : tags) { Class<? extends Tag> type = getById(tag); if (type != null && !Property.class.isAssignableFrom(type)) { return type; } } if (getProperty(item) != null) { StateDescription stateDescription = item.getStateDescription(); if (stateDescription != null && stateDescription.isReadOnly()) { return Measurement.class; } else { return org.openhab.core.semantics.model.point.Control.class; } } else { return null; } }  static @Nullable Class<? extends Tag> getById(String tagId); static @Nullable Class<? extends Tag> getByLabel(String tagLabel, Locale locale); static List<Class<? extends Tag>> getByLabelOrSynonym(String tagLabelOrSynonym, Locale locale); static List<String> getLabelAndSynonyms(Class<? extends Tag> tag, Locale locale); static String getLabel(Class<? extends Tag> tag, Locale locale); static @Nullable Class<? extends Tag> getSemanticType(Item item); @SuppressWarnings("unchecked") static @Nullable Class<? extends Property> getProperty(Item item);  }
@Test public void testGetSemanticType() { assertEquals(Bathroom.class, SemanticTags.getSemanticType(locationItem)); assertEquals(CleaningRobot.class, SemanticTags.getSemanticType(equipmentItem)); assertEquals(Measurement.class, SemanticTags.getSemanticType(pointItem)); }