Search in sources :

Example 1 with Condition

use of org.openhab.binding.weather.internal.model.Condition in project openhab1-addons by openhab.

the class CommonIdHandler method setCommonId.

/**
     * Sets the common condition id into the weather object.
     */
public void setCommonId(Weather weather) {
    Map<String, CommonId> commonIds = providerCommonIds.get(weather.getProvider());
    if (commonIds == null) {
        throw new RuntimeException("No common ids for provider " + weather.getProvider() + " declared");
    }
    Condition cond = weather.getCondition();
    CommonId cid = commonIds.get(cond.getId());
    if (cid == null) {
        cid = commonIds.get(cond.getIcon());
    }
    if (cid != null) {
        cond.setCommonId(cid.getId());
    } else {
        ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("provider", weather.getProvider()).append("id", cond.getId()).append("icon", cond.getIcon());
        logger.warn("CommonId not found: {}", tsb.toString());
    }
}
Also used : CommonId(org.openhab.binding.weather.internal.model.common.CommonId) Condition(org.openhab.binding.weather.internal.model.Condition) ToStringBuilder(org.apache.commons.lang.builder.ToStringBuilder)

Aggregations

ToStringBuilder (org.apache.commons.lang.builder.ToStringBuilder)1 Condition (org.openhab.binding.weather.internal.model.Condition)1 CommonId (org.openhab.binding.weather.internal.model.common.CommonId)1