Search in sources :

Example 11 with GenericItem

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);
    }
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem)

Example 12 with GenericItem

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);
    }
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem)

Example 13 with GenericItem

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;
}
Also used : GroupItem(org.eclipse.smarthome.core.items.GroupItem) GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item) ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 14 with GenericItem

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();
        }
    };
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) List(java.util.List) Before(org.junit.Before)

Example 15 with GenericItem

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));
}
Also used : GenericItem(org.eclipse.smarthome.core.items.GenericItem) ByteArrayInputStream(java.io.ByteArrayInputStream) GroupItem(org.eclipse.smarthome.core.items.GroupItem) JavaOSGiTest(org.eclipse.smarthome.test.java.JavaOSGiTest) Test(org.junit.Test)

Aggregations

GenericItem (org.eclipse.smarthome.core.items.GenericItem)27 GroupItem (org.eclipse.smarthome.core.items.GroupItem)10 Item (org.eclipse.smarthome.core.items.Item)10 ItemNotFoundException (org.eclipse.smarthome.core.items.ItemNotFoundException)6 Test (org.junit.Test)4 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 RolesAllowed (javax.annotation.security.RolesAllowed)2 Path (javax.ws.rs.Path)2 ActiveItem (org.eclipse.smarthome.core.items.ActiveItem)2 RollershutterItem (org.eclipse.smarthome.core.library.items.RollershutterItem)2 SwitchItem (org.eclipse.smarthome.core.library.items.SwitchItem)2 ModelGroupItem (org.eclipse.smarthome.model.items.ModelGroupItem)2 ModelNormalItem (org.eclipse.smarthome.model.items.ModelNormalItem)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1