Search in sources :

Example 1 with ProfileFactory

use of org.eclipse.smarthome.core.thing.profiles.ProfileFactory in project smarthome by eclipse.

the class CommunicationManager method getProfileFromFactories.

@Nullable
private Profile getProfileFromFactories(ProfileTypeUID profileTypeUID, ItemChannelLink link, ProfileCallback callback) {
    ProfileContextImpl context = new ProfileContextImpl(link.getConfiguration());
    if (supportsProfileTypeUID(defaultProfileFactory, profileTypeUID)) {
        logger.trace("using the default ProfileFactory to create profile '{}'", profileTypeUID);
        return defaultProfileFactory.createProfile(profileTypeUID, callback, context);
    }
    for (Entry<ProfileFactory, Set<String>> entry : profileFactories.entrySet()) {
        ProfileFactory factory = entry.getKey();
        if (supportsProfileTypeUID(factory, profileTypeUID)) {
            logger.trace("using ProfileFactory '{}' to create profile '{}'", factory, profileTypeUID);
            Profile profile = factory.createProfile(profileTypeUID, callback, context);
            if (profile == null) {
                logger.error("ProfileFactory '{}' returned 'null' although it claimed it supports item type '{}'", factory, profileTypeUID);
            } else {
                entry.getValue().add(link.getUID());
                return profile;
            }
        }
    }
    logger.debug("no ProfileFactory found which supports '{}'", profileTypeUID);
    return null;
}
Also used : Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) HashSet(java.util.HashSet) ProfileFactory(org.eclipse.smarthome.core.thing.profiles.ProfileFactory) SystemProfileFactory(org.eclipse.smarthome.core.thing.internal.profiles.SystemProfileFactory) StateProfile(org.eclipse.smarthome.core.thing.profiles.StateProfile) TriggerProfile(org.eclipse.smarthome.core.thing.profiles.TriggerProfile) Profile(org.eclipse.smarthome.core.thing.profiles.Profile) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 SystemProfileFactory (org.eclipse.smarthome.core.thing.internal.profiles.SystemProfileFactory)1 Profile (org.eclipse.smarthome.core.thing.profiles.Profile)1 ProfileFactory (org.eclipse.smarthome.core.thing.profiles.ProfileFactory)1 StateProfile (org.eclipse.smarthome.core.thing.profiles.StateProfile)1 TriggerProfile (org.eclipse.smarthome.core.thing.profiles.TriggerProfile)1