use of org.eclipse.smarthome.core.items.GenericItem in project smarthome by eclipse.
the class RuleEngineImpl method internalItemRemoved.
private void internalItemRemoved(Item item) {
if (item instanceof GenericItem) {
GenericItem genericItem = (GenericItem) item;
genericItem.removeStateChangeListener(this);
}
}
use of org.eclipse.smarthome.core.items.GenericItem in project smarthome by eclipse.
the class ItemRegistryImpl method injectServices.
private void injectServices(Item item) {
if (item instanceof GenericItem) {
GenericItem genericItem = (GenericItem) item;
genericItem.setEventPublisher(eventPublisher);
genericItem.setStateDescriptionService(stateDescriptionService);
genericItem.setUnitProvider(unitProvider);
genericItem.setItemStateConverter(itemStateConverter);
}
}
use of org.eclipse.smarthome.core.items.GenericItem in project smarthome by eclipse.
the class ItemRegistryImpl method getItemsByTag.
@Override
@SuppressWarnings("unchecked")
public <T extends GenericItem> Collection<T> getItemsByTag(Class<T> typeFilter, String... tags) {
Collection<T> filteredItems = new ArrayList<T>();
Collection<Item> items = getItemsByTag(tags);
for (Item item : items) {
if (typeFilter.isInstance(item)) {
filteredItems.add((T) item);
}
}
return filteredItems;
}
use of org.eclipse.smarthome.core.items.GenericItem in project smarthome by eclipse.
the class PersistenceExtensionsTest method setUp.
@Before
public void setUp() {
ext = new PersistenceExtensions();
ext.setPersistenceServiceRegistry(registry);
item = new GenericItem("Test", "Test") {
@Override
public List<Class<? extends State>> getAcceptedDataTypes() {
return Collections.emptyList();
}
@Override
public List<Class<? extends Command>> getAcceptedCommandTypes() {
return Collections.emptyList();
}
};
}
use of org.eclipse.smarthome.core.items.GenericItem in project smarthome by eclipse.
the class GenericItemProvider2Test method testGroupAssignmentsAreConsidered.
@Test
public void testGroupAssignmentsAreConsidered() {
assertThat(itemRegistry.getAll().size(), is(0));
String model = //
"Group testGroup " + //
"Number number1 (testGroup) " + "Number number2 ";
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
model = //
"Group testGroup " + //
"Number number1 (testGroup) " + "Number number2 (testGroup)";
modelRepository.addOrRefreshModel(TESTMODEL_NAME, new ByteArrayInputStream(model.getBytes()));
GenericItem item = (GenericItem) itemRegistry.get("number2");
assertTrue(item.getGroupNames().contains("testGroup"));
GroupItem groupItem = (GroupItem) itemRegistry.get("testGroup");
assertTrue(groupItem.getAllMembers().contains(item));
}
Aggregations