Search in sources :

Example 1 with ProfileType

use of org.openhab.core.thing.profiles.ProfileType in project addons by smarthomej.

the class BasicProfilesFactory method createLocalizedProfileType.

private ProfileType createLocalizedProfileType(ProfileType profileType, @Nullable Locale locale) {
    final LocalizedKey localizedKey = new LocalizedKey(profileType.getUID(), locale != null ? locale.toLanguageTag() : null);
    final ProfileType cachedlocalizedProfileType = localizedProfileTypeCache.get(localizedKey);
    if (cachedlocalizedProfileType != null) {
        return cachedlocalizedProfileType;
    }
    final ProfileType localizedProfileType = profileTypeI18nLocalizationService.createLocalizedProfileType(bundle, profileType, locale);
    if (localizedProfileType != null) {
        localizedProfileTypeCache.put(localizedKey, localizedProfileType);
        return localizedProfileType;
    } else {
        return profileType;
    }
}
Also used : LocalizedKey(org.openhab.core.i18n.LocalizedKey) ProfileType(org.openhab.core.thing.profiles.ProfileType)

Example 2 with ProfileType

use of org.openhab.core.thing.profiles.ProfileType in project addons by smarthomej.

the class MathTransformationProfileFactoryTest method systemProfileTypesAndUidsShouldBeAvailable.

@Test
public void systemProfileTypesAndUidsShouldBeAvailable() {
    Collection<ProfileTypeUID> supportedProfileTypeUIDs = profileFactory.getSupportedProfileTypeUIDs();
    assertThat(supportedProfileTypeUIDs, hasSize(NUMBER_OF_PROFILES));
    Collection<ProfileType> supportedProfileTypes = profileFactory.getProfileTypes(null);
    assertThat(supportedProfileTypeUIDs, hasSize(NUMBER_OF_PROFILES));
    for (ProfileType profileType : supportedProfileTypes) {
        assertTrue(supportedProfileTypeUIDs.contains(profileType.getUID()));
    }
}
Also used : ProfileType(org.openhab.core.thing.profiles.ProfileType) ProfileTypeUID(org.openhab.core.thing.profiles.ProfileTypeUID) Test(org.junit.jupiter.api.Test)

Example 3 with ProfileType

use of org.openhab.core.thing.profiles.ProfileType in project openhab-core by openhab.

the class SystemProfileFactory method createLocalizedProfileType.

private ProfileType createLocalizedProfileType(ProfileType profileType, @Nullable Locale locale) {
    LocalizedKey localizedKey = new LocalizedKey(profileType.getUID(), locale != null ? locale.toLanguageTag() : null);
    ProfileType cachedEntry = localizedProfileTypeCache.get(localizedKey);
    if (cachedEntry != null) {
        return cachedEntry;
    }
    ProfileType localizedProfileType = profileTypeI18nLocalizationService.createLocalizedProfileType(bundle, profileType, locale);
    if (localizedProfileType != null) {
        localizedProfileTypeCache.put(localizedKey, localizedProfileType);
        return localizedProfileType;
    } else {
        return profileType;
    }
}
Also used : LocalizedKey(org.openhab.core.i18n.LocalizedKey) ProfileType(org.openhab.core.thing.profiles.ProfileType)

Example 4 with ProfileType

use of org.openhab.core.thing.profiles.ProfileType in project addons by smarthomej.

the class BasicProfilesFactoryTest method systemProfileTypesAndUidsShouldBeAvailable.

@Test
public void systemProfileTypesAndUidsShouldBeAvailable() {
    Collection<ProfileTypeUID> supportedProfileTypeUIDs = profileFactory.getSupportedProfileTypeUIDs();
    assertThat(supportedProfileTypeUIDs, hasSize(NUMBER_OF_PROFILES));
    Collection<ProfileType> supportedProfileTypes = profileFactory.getProfileTypes(null);
    assertThat(supportedProfileTypeUIDs, hasSize(NUMBER_OF_PROFILES));
    for (ProfileType profileType : supportedProfileTypes) {
        assertTrue(supportedProfileTypeUIDs.contains(profileType.getUID()));
    }
}
Also used : ProfileType(org.openhab.core.thing.profiles.ProfileType) ProfileTypeUID(org.openhab.core.thing.profiles.ProfileTypeUID) Test(org.junit.jupiter.api.Test)

Example 5 with ProfileType

use of org.openhab.core.thing.profiles.ProfileType in project addons by smarthomej.

the class MathTransformationProfileFactory method createLocalizedProfileType.

private ProfileType createLocalizedProfileType(ProfileType profileType, @Nullable Locale locale) {
    final LocalizedKey localizedKey = new LocalizedKey(profileType.getUID(), locale != null ? locale.toLanguageTag() : null);
    final ProfileType cachedlocalizedProfileType = localizedProfileTypeCache.get(localizedKey);
    if (cachedlocalizedProfileType != null) {
        return cachedlocalizedProfileType;
    }
    final ProfileType localizedProfileType = profileTypeI18nLocalizationService.createLocalizedProfileType(bundle, profileType, locale);
    if (localizedProfileType != null) {
        localizedProfileTypeCache.put(localizedKey, localizedProfileType);
        return localizedProfileType;
    } else {
        return profileType;
    }
}
Also used : LocalizedKey(org.openhab.core.i18n.LocalizedKey) ProfileType(org.openhab.core.thing.profiles.ProfileType)

Aggregations

ProfileType (org.openhab.core.thing.profiles.ProfileType)7 LocalizedKey (org.openhab.core.i18n.LocalizedKey)3 Test (org.junit.jupiter.api.Test)2 ProfileTypeUID (org.openhab.core.thing.profiles.ProfileTypeUID)2 Operation (io.swagger.v3.oas.annotations.Operation)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 TriggerProfileType (org.openhab.core.thing.profiles.TriggerProfileType)1 ChannelType (org.openhab.core.thing.type.ChannelType)1 ChannelTypeUID (org.openhab.core.thing.type.ChannelTypeUID)1