Java Code Examples for org.apache.commons.lang.StringUtils#trim()

The following examples show how to use org.apache.commons.lang.StringUtils#trim() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityAttribute.java    From atlas with Apache License 2.0 6 votes vote down vote up
public EntityAttribute(String attributeKey, TransformerContext context) {
    this.attributeKey = attributeKey;

    int idx = attributeKey != null ? attributeKey.indexOf(TYPE_NAME_ATTRIBUTE_NAME_SEP) : -1;

    if (idx != -1) {
        this.attributeName = StringUtils.trim(attributeKey.substring(idx + 1));

        AtlasTypeRegistry typeRegistry = context != null ? context.getTypeRegistry() : null;

        if (typeRegistry != null) {
            String typeName = StringUtils.trim(attributeKey.substring(0, idx));

            this.entityType = typeRegistry.getEntityTypeByName(typeName);
        } else {
            this.entityType = null;
        }
    } else {
        this.entityType    = null;
        this.attributeName = attributeKey;
    }
}
 
Example 2
Source File: SQLServerDialect.java    From ymate-platform-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public String buildPagedQuerySQL(String originSql, int page, int pageSize) {
    int _limit = ((page - 1) * pageSize);
    String _tmpSQL = StringUtils.trim(originSql);
    if (StringUtils.startsWithIgnoreCase(_tmpSQL, SELECT)) {
        _tmpSQL = StringUtils.trim(StringUtils.substring(_tmpSQL, SELECT.length()));
    }
    boolean distinct = false;
    if (StringUtils.startsWithIgnoreCase(_tmpSQL, DISTINCT)) {
        _tmpSQL = StringUtils.substring(_tmpSQL, DISTINCT.length());
        distinct = true;
    }
    return ExpressionUtils.bind("SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY __tc__) __rn__, * FROM (SELECT ${_distinct} TOP ${_limit} 0 __tc__, ${_sql}) t) tt WHERE __rn__ > ${_offset}")
            .set("_distinct", distinct ? DISTINCT : StringUtils.EMPTY)
            .set("_limit", String.valueOf(_limit + pageSize))
            .set("_sql", _tmpSQL)
            .set("_offset", String.valueOf(_limit)).getResult();
}
 
Example 3
Source File: YuGongController.java    From yugong with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 从表白名单中得到shardKey
 *
 * @param tableName 带有shardkey的表, 例子 yugong_example_oracle#pk|name
 */
private String getExtKey(String tableName) {
    if (StringUtils.isEmpty(tableName)) {
        return null;
    }

    String[] paramArray = tableName.split("#");
    if (paramArray.length == 1) {
        return null;
    } else if (paramArray.length == 2) {
        return StringUtils.trim(paramArray[1]);
    } else {
        // 其他情况
        return null;
    }
}
 
Example 4
Source File: SqueezeboxGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
private SqueezeboxBindingConfig parseBindingConfig(String bindingConfig) throws BindingConfigParseException {
    String[] configParts = bindingConfig.split(":");

    if (configParts.length < 2) {
        throw new BindingConfigParseException(
                "Squeezebox binding configuration must consist of two parts [config=" + configParts + "]");
    }

    String playerId = StringUtils.trim(configParts[0]);

    String command = StringUtils.trim(configParts[1]);
    CommandType commandType = CommandType.fromString(command);

    String extra = null;
    if (configParts.length > 2) {
        extra = configParts[2];
    }
    for (int i = 3; i < configParts.length; i++) {
        extra += ":" + configParts[i];
    }

    return new SqueezeboxBindingConfig(playerId, commandType, extra);
}
 
Example 5
Source File: PreparePackageIdsTask.java    From atlas with Apache License 2.0 6 votes vote down vote up
/**
 * Read the component's packageId
 *
 * @param packageIdFile
 * @return
 */
private Map<String, String> loadPackageIdProperties(File packageIdFile) throws IOException {
    Map<String, String> values = new HashMap<String, String>();
    if (null != packageIdFile && packageIdFile.exists() && packageIdFile.isFile()) {
        List<String> lines = FileUtils.readLines(packageIdFile);
        for (String line : lines) {
            String[] lineValues = StringUtils.split(line, "=");
            if (null != lineValues && lineValues.length >= 2) {
                String key = StringUtils.trim(lineValues[0]);
                String value = StringUtils.trim(lineValues[1]);
                values.put(key, value);
            }
        }
    }
    return values;
}
 
Example 6
Source File: VDRGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Checks if the bindingConfig contains a valid binding type and returns an
 * appropriate instance.
 * 
 * @param item
 * @param bindingConfig
 * 
 * @throws BindingConfigParseException
 *             if bindingConfig is no valid binding type
 */
protected VDRBindingConfig parseBindingConfig(Item item, String bindingConfigs, VDRBindingConfig parent)
        throws BindingConfigParseException {

    String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
    String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");

    String[] configParts = bindingConfig.split(":");
    if (configParts.length != 2) {
        throw new BindingConfigParseException(
                "VDR binding configuration must consist of two parts [config=" + configParts + "]");
    }

    String vdrId = StringUtils.trim(configParts[0]);
    String command = StringUtils.trim(configParts[1]);

    if (command != null) {
        if (VDRCommandType.validateBinding(command, item.getClass())) {
            VDRBindingConfig vdrBindingConfig = new VDRBindingConfig(vdrId, command, item, parent);
            if (StringUtils.isNotBlank(bindingConfigTail)) {
                parseBindingConfig(item, bindingConfigTail, vdrBindingConfig);
            }
            return vdrBindingConfig;
        } else {
            String validItemType = VDRCommandType.getValidItemTypes(command);
            if (StringUtils.isEmpty(validItemType)) {
                throw new BindingConfigParseException("'" + bindingConfig + "' is no valid binding type");
            } else {
                throw new BindingConfigParseException("'" + bindingConfig
                        + "' is not bound to a valid item type. Valid item type(s): " + validItemType);
            }
        }
    } else {
        throw new BindingConfigParseException("'" + bindingConfig + "' is no valid binding type");
    }
}
 
Example 7
Source File: AbstractLaunchDelegate.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected static void appendArg(StringBuilder sb, String txt, String err) throws CoreException {
	txt = StringUtils.trim(txt);
    if (txt == null || txt.isEmpty() || txt.equals(Sdk.NOT_SUPPORTED)) {
        if (err != null) {
            abortLaunch(Messages.AbstractLaunchDelegate_NotSpecified + ": " + err); //$NON-NLS-1$
        }
    } else {
        if (txt.indexOf(' ') > -1) {
            sb.append('"').append(txt).append("\" "); //$NON-NLS-1$
        } else {
            sb.append(txt);
        }
    }
}
 
Example 8
Source File: LikeUtil.java    From yugong with GNU General Public License v2.0 5 votes vote down vote up
private static String buildPattern(String pattern, String escape) {
    char esc = escape.charAt(0);
    pattern = StringUtils.trim(pattern);
    StringBuilder builder = new StringBuilder("^");
    int index = 0, last = 0;
    while (true) {
        // 查找esc
        index = pattern.indexOf(esc, last);
        if (index == -1 || index >= pattern.length()) {
            if (last < pattern.length()) {
                builder.append(convertWildcard(ripRegex(pattern.substring(last))));
            }
            break;
        }
        if (index > 0) {
            String toRipRegex = StringUtils.substring(pattern, last, index);
            builder.append(convertWildcard(ripRegex(toRipRegex)));
            last = index;
        }
        if (index + 1 < pattern.length()) {
            builder.append(ripRegex(pattern.charAt(index + 1)));
            last = index + 2;
        } else {
            builder.append(pattern.charAt(index));
            last = index + 1;
        }
        if (last >= pattern.length()) {
            break;
        }
    }
    builder.append('$');
    return builder.toString();
}
 
Example 9
Source File: BaseDataUtil.java    From sofa-acts with Apache License 2.0 5 votes vote down vote up
/**
 * read test case from yaml file.
 * @param str
 * @param classLoader
 * @return
 */
public static Map<String, PrepareData> loadFromYaml(String str, ClassLoader classLoader) {

    try {
        Yaml yaml = new Yaml(new BaseDataUtil.SelectiveConstructor(classLoader),
            new BaseDataUtil.myRepresenter());
        return (Map<String, PrepareData>) yaml.load(str);

    } catch (ActsException e) {
        String sberr = e.getMessage();
        if (StringUtils.contains(sberr, " Cannot create property=")) {
            String filedName = StringUtils.substringBetween(sberr, "Unable to find property '",
                "' on class");
            if (StringUtils.isBlank(filedName)) {
                if (StringUtils.contains(sberr, "Class not found")) {
                    String clsName = StringUtils.substringBetween(sberr, "Class not found:",
                        ";");
                    throw new ActsException(
                        "class "
                                + clsName
                                + " failed to load, it is recommended to import the project after re-mvn!");
                }
            } else {
                throw new ActsException("Please remove this field in csv or yaml!"
                                        + StringUtils.trim(filedName));
            }

        }
        throw new ActsException("Throw an exception when reading yaml", e);
    }

}
 
Example 10
Source File: AbstractAnnotationHandler.java    From framework with Apache License 2.0 5 votes vote down vote up
/**
 * Description: <br>
 * 
 * @author 王伟<br>
 * @taskId <br>
 * @param method
 * @return String
 * @throws InitializationException <br>
 */
protected String cacheSqlTemplate(final Method method) throws InitializationException {
    String key = CacheHelper.buildKey(method.getDeclaringClass().getName(), BeanUtil.getMethodSignature(method));
    String templateSql = null;
    try {
        templateSql = daoConfig.isCache() ? CacheHelper.getCache().get(CacheConstant.SQL_DIR, key) : null;
        if (StringUtils.isEmpty(templateSql)) {
            String path = null;

            // 获取方法的SQL标签
            if (method.isAnnotationPresent(Sql.class)) {
                Sql sql = method.getAnnotation(Sql.class);
                templateSql = sql.value();
                path = sql.path();
            }

            if (StringUtils.isEmpty(templateSql)) {
                templateSql = checkSqlPath(method, path);
            }
            if (daoConfig.isCache()) {
                CacheHelper.getCache().put(CacheConstant.SQL_DIR, key, templateSql);
            }
        }
    }
    catch (Exception e) {
        throw new InitializationException(ErrorCodeDef.CACHE_ERROR_10002, e);
    }
    return StringUtils.trim(templateSql);
}
 
Example 11
Source File: MpdGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 5 votes vote down vote up
protected void parseBindingConfig(String bindingConfigs, MpdBindingConfig config)
        throws BindingConfigParseException {

    String bindingConfig = StringUtils.substringBefore(bindingConfigs, ",");
    String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ",");

    String[] configParts = bindingConfig.split(":");
    if (configParts.length != 3) {
        throw new BindingConfigParseException(
                "MPD binding configuration must consist of three parts [config=" + configParts + "]");
    }

    String command = StringUtils.trim(configParts[0]);
    String playerId = StringUtils.trim(configParts[1]);
    String playerCommand = StringUtils.trim(configParts[2]);
    // check for optional command=param binding
    String[] playerCommandParts = playerCommand.split("=");
    if (playerCommandParts.length == 2) {
        // rewrite command=param -> command
        playerCommand = StringUtils.trim(playerCommandParts[0]);
        String playerCommandParam = StringUtils.trim(playerCommandParts[1]);
        // save the param in the config
        config.put(command + PARAM_SUFFIX, playerCommandParam);
    }

    // if there are more commands to parse do that recursively ...
    if (StringUtils.isNotBlank(bindingConfigTail)) {
        parseBindingConfig(bindingConfigTail, config);
    }

    config.put(command, playerId + ":" + playerCommand);
}
 
Example 12
Source File: UrlFactory.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public static String parameterizeUrl(String baseUrl, Properties params) {
    baseUrl = StringUtils.trim(baseUrl);
    if (StringUtils.isEmpty(baseUrl)) {
        throw new IllegalArgumentException("invalid (blank) base URL");
    }
    if (params == null) {
        throw new IllegalArgumentException("invalid (null) Properties");
    }


    StringBuffer ret = new StringBuffer(baseUrl);
    // Only start with ? if it has not been added to the url
    String delimiter = (ret.indexOf("?") == -1) ? "?" : "&";
    for ( Object key : params.keySet() ) {
        String paramName = StringUtils.trim( (String)key );
        String paramValue = params.getProperty(paramName);
        ret.append( delimiter );
        if (StringUtils.isEmpty(paramName)) {
            throw new IllegalArgumentException("invalid (blank) paramName");
        }
        if (paramValue == null) {
            ret.append( paramName );
            ret.append( "=" );
        } else {
            try {
                ret.append( paramName );
                ret.append( "=" );
                ret.append( urlCodec.encode(paramValue) );
            } catch ( EncoderException ex ) {
                LOG.error("Unable to encode parameter name or value: " + paramName + "=" + paramValue, ex);
                throw new RuntimeException( "Unable to encode parameter name or value: " + paramName + "=" + paramValue, ex );
            }
        }
        delimiter = "&";
    }

    return ret.toString();
}
 
Example 13
Source File: DoctrineOrmRepositoryIntention.java    From idea-php-annotation-plugin with MIT License 5 votes vote down vote up
private void insertAttribute(@NotNull Editor editor, @NotNull String repositoryClass, @NotNull PhpDocTag phpDocTag, @Nullable PhpPsiElement firstPsiChild) {
    if(firstPsiChild == null) return;

    String attr = "repositoryClass=\"" + repositoryClass + "\"";

    // we already have an attribute list
    if(firstPsiChild.getNode().getElementType() == PhpDocElementTypes.phpDocAttributeList) {

        // AttributeList: "()", "(aaa)"
        String text = StringUtils.trim(firstPsiChild.getText());
        text = StringUtils.strip(text, "(");
        text = StringUtils.strip(text, ")");

        if (text.contains(attr)) {
            return;
        }

        if(text.length() == 0) {
            // @ORM\Entity()
            editor.getDocument().insertString(firstPsiChild.getTextRange().getStartOffset() + 1, attr);
        } else {
            // @ORM\Entity(readOnly=true)
            editor.getDocument().insertString(firstPsiChild.getTextRange().getStartOffset() + 1, attr + ", ");
        }

        return;
    }

    // @ORM\Entity
    PsiElement firstChild = phpDocTag.getFirstChild();
    if(firstChild != null) {
        editor.getDocument().insertString(firstChild.getTextRange().getEndOffset(), "(" + attr + ")");
    }
}
 
Example 14
Source File: AppDeployCenterImpl.java    From cachecloud with Apache License 2.0 4 votes vote down vote up
@Override
    public boolean allocateResourceApp(Long appAuditId, List<String> nodeInfoList, AppUser auditUser) {
        if (appAuditId == null || appAuditId <= 0L) {
            logger.error("appAuditId is null");
            return false;
        }
        if (nodeInfoList == null || nodeInfoList.isEmpty()) {
            logger.error("nodeInfoList is null");
            return false;
        }
        AppAudit appAudit = appAuditDao.getAppAudit(appAuditId);
        if (appAudit == null) {
            logger.error("appAudit:id={} is not exist", appAuditId);
            return false;
        }
        long appId = appAudit.getAppId();
        AppDesc appDesc = appService.getByAppId(appId);
        if (appDesc == null) {
            logger.error("appDesc:id={} is not exist");
            return false;
        }
        int type = appDesc.getType();
        List<String[]> nodes = new ArrayList<String[]>();
        for (String nodeInfo : nodeInfoList) {
            nodeInfo = StringUtils.trim(nodeInfo);
            if (StringUtils.isBlank(nodeInfo)) {
                continue;
            }
            String[] array = nodeInfo.split(":");
//            if (array.length < 2) {
//                logger.error("error nodeInfo:{}", Arrays.toString(array));
//                continue;
//            }
            nodes.add(array);
        }

        boolean isAudited = false;
        if (TypeUtil.isRedisType(type)) {
            if (TypeUtil.isRedisCluster(type)) {
                isAudited = deployCluster(appId, nodes);
            } else if (nodes.size() > 0) {
                if (TypeUtil.isRedisSentinel(type)) {
                    isAudited = deploySentinel(appId, nodes);
                } else {
                    isAudited = deployStandalone(appId, nodes.get(0));
                }
            } else {
                logger.error("nodeInfoList={} is error", nodeInfoList);
            }
        } else {
            logger.error("unknown type : {}", type);
            return false;
        }

        //审核通过
        if (isAudited) {
            // 改变审核状态
            appAuditDao.updateAppAudit(appAudit.getId(), AppCheckEnum.APP_ALLOCATE_RESOURCE.value());
        }

        return true;
    }
 
Example 15
Source File: CSRFServlet.java    From easybuggy with Apache License 2.0 4 votes vote down vote up
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    Locale locale = req.getLocale();
    HttpSession session = req.getSession();
    if (session == null) {
        res.sendRedirect("/");
        return;
    }
    String userid = (String) session.getAttribute("userid");
    String password = StringUtils.trim(req.getParameter("password"));
    if (!StringUtils.isBlank(userid) && !StringUtils.isBlank(password) && password.length() >= 8) {
        try {
            DefaultClientAttribute entryAttribute = new DefaultClientAttribute("userPassword", encodeForLDAP(password.trim()));
            ClientModification clientModification = new ClientModification();
            clientModification.setAttribute(entryAttribute);
            clientModification.setOperation(ModificationOperation.REPLACE_ATTRIBUTE);
            ModifyRequestImpl modifyRequest = new ModifyRequestImpl(1);
            modifyRequest.setName(new LdapDN("uid=" + encodeForLDAP(userid.trim()) + ",ou=people,dc=t246osslab,dc=org"));
            modifyRequest.addModification(clientModification);
            EmbeddedADS.getAdminSession().modify(modifyRequest);

            StringBuilder bodyHtml = new StringBuilder();
            bodyHtml.append("<form>");
            bodyHtml.append(getMsg("msg.passwd.changed", locale));
            bodyHtml.append("<br><br>");
            bodyHtml.append("<a href=\"/admins/main\">" + getMsg("label.goto.admin.page", locale) + "</a>");
            bodyHtml.append("</form>");
            responseToClient(req, res, getMsg("title.csrf.page", locale), bodyHtml.toString());
        } catch (Exception e) {
            log.error("Exception occurs: ", e);
            req.setAttribute("errorMessage", getErrMsg("msg.passwd.change.failed", locale));
            doGet(req, res);
        }
    } else {
        if (StringUtils.isBlank(password) || password.length() < 8) {
            req.setAttribute("errorMessage", getErrMsg("msg.passwd.is.too.short", locale));
        } else {
            req.setAttribute("errorMessage", getErrMsg("msg.unknown.exception.occur",
                    new String[] { "userid: " + userid }, locale));
        }
        doGet(req, res);
    }
}
 
Example 16
Source File: BaseDataUtil.java    From sofa-acts with Apache License 2.0 4 votes vote down vote up
/**
 * read test case from yaml file.
 *
 * @param folder he package where yaml is
 * @param classLoader
 * @param encoding
 * @return
 */
public static Map<String, PrepareData> loadFromYamlByCase(File folder, ClassLoader classLoader,
                                                          String encoding) {

    Map<String, PrepareData> caseMap = new HashMap<String, PrepareData>();
    if (folder.exists()) {
        try {
            File[] files = folder.listFiles();

            for (File file : files) {
                if (file.getAbsolutePath().endsWith("yaml")) {
                    String str = FileUtils.readFileToString(file, encoding);

                    Yaml yaml = new Yaml(new BaseDataUtil.SelectiveConstructor(classLoader),
                        new BaseDataUtil.myRepresenter());
                    caseMap.putAll((Map<String, PrepareData>) yaml.load(str));
                }
            }

        } catch (Exception e) {
            String sberr = e.getMessage();
            if (StringUtils.contains(sberr, " Cannot create property=")) {
                String filedName = StringUtils.substringBetween(sberr,
                    "Unable to find property '", "' on class");
                if (StringUtils.isBlank(filedName)) {
                    if (StringUtils.contains(sberr, "Class not found")) {
                        String clsName = StringUtils.substringBetween(sberr,
                            "Class not found:", ";");
                        throw new ActsException(
                            "class "
                                    + clsName
                                    + "failed to load, it is recommended to import the project after re-mvn!");
                    }
                } else {
                    throw new ActsException("Please remove this field in csv or yaml!"
                                            + StringUtils.trim(filedName));
                }

            }
            throw new ActsException("Throw an exception when reading yaml", e);
        }
    }

    return caseMap;

}
 
Example 17
Source File: ConfigurationImpl.java    From freehealth-connector with GNU Affero General Public License v3.0 4 votes vote down vote up
public String getProperty(String key, String defaultValue) {
   String value = this.getProperties().getProperty(key, defaultValue);
   return key == null || !this.endpointToTrim(key) && !this.elseToTrim(key) ? value : StringUtils.trim(value);
}
 
Example 18
Source File: TouchFile.java    From molicode with Apache License 2.0 4 votes vote down vote up
public static TouchFile parseExpression(String expression) {
    expression = StringUtils.trim(expression);
    if (StringUtils.isEmpty(expression)) {
        return null;
    }

    String[] expSplit = expression.split("=");
    if (expSplit.length != 2) {
        return null;
    }

    try {
        TouchFile touchFile = new TouchFile();
        touchFile.setExpression(expression);
        touchFile.setOriginExpression(expSplit[0]);
        touchFile.setTargetExpression(expSplit[1]);

        String[] orgPath = touchFile.getOriginExpression().split("/");
        String[] tarPath = touchFile.getTargetExpression().split("/");

        touchFile.setOriginPathList(parseStrArr2List(orgPath));
        touchFile.setTargetPathList(parseStrArr2List(tarPath));
        //如果为空,直接返回nuLl
        if (touchFile.getOriginPathList().isEmpty() || touchFile.getTargetPathList().isEmpty()) {
            return null;
        }

        if (orgPath.length < tarPath.length) {
            touchFile.setTouchFileType(TouchFileType.EXTEND_DIR);
        } else if (orgPath.length > tarPath.length) {
            touchFile.setTouchFileType(TouchFileType.SHORTEN_DIR);
        } else {
            touchFile.setTouchFileType(TouchFileType.EXCHANGE_DIR);
        }
        touchFile.parseDirTrans();

        return touchFile;
    } catch (Exception e) {
        LogHelper.EXCEPTION.error("解析touchFile表达式失败,exp={}", expression, e);
    }
    return null;
}
 
Example 19
Source File: JAXBConfigImpl.java    From rice with Educational Community License v2.0 4 votes vote down vote up
protected void doImport(Param p, Unmarshaller unmarshaller, int depth) throws IOException {
    String configLocation = StringUtils.trim(parseValue(p.getValue(), new HashSet<String>()));
    parseConfig(configLocation, unmarshaller, depth + 1);
}
 
Example 20
Source File: RWESmarthomeGenericBindingProvider.java    From openhab1-addons with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig)
        throws BindingConfigParseException {
    super.processBindingConfiguration(context, item, bindingConfig);
    RWESmarthomeBindingConfig config = new RWESmarthomeBindingConfig();

    // parse config
    bindingConfig = StringUtils.trimToEmpty(bindingConfig);
    String[] configstrings = bindingConfig.split("[,]");

    Pattern patternForId = Pattern.compile("^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$");
    Pattern patternForParam = Pattern.compile(
            "^(temperature|humidity|settemperature|variable|contact|switch|operationmodeauto|luminance|smokedetector|dimmer|dimmerinverted|rollershutter|rollershutterinverted|alarm|totalenergy|energypermonthinkwh|energypermonthineuro|energyperdayinkwh|energyperdayineuro|powerinwatt)$");

    for (String configstring : configstrings) {
        String[] configParts = StringUtils.trimToEmpty(configstring).split("[=]");
        if (configParts.length != 2) {
            throw new BindingConfigParseException("Each entry must have a key and a value");
        }

        String key = StringUtils.trim(configParts[0]);
        String value = StringUtils.trim(configParts[1]);

        // id
        if ("id".equalsIgnoreCase(key)) {
            if (!patternForId.matcher(value).matches()) {
                throw new BindingConfigParseException("id '" + value
                        + "' is not a valid logicalDeviceId. Valid example: 12345a67-890b-1c23-de45-f67890123456");
            }
            config.setDeviceId(value);

            // param
        } else if ("param".equalsIgnoreCase(key)) {
            if (!patternForParam.matcher(value).matches()) {
                throw new BindingConfigParseException(
                        "Invalid configuration: 'param' must be one of the following: temperature|humidity|settemperature|variable|contact|switch|operationmodeauto|luminance|smokedetector|dimmer|dimmerinverted|rollershutter|rollershutterinverted|alarm|totalenergy|energypermonthinkwh|energypermonthineuro|energyperdayinkwh|energyperdayineuro|powerinwatt");
            }
            config.setDeviceParam(value);

            // unknown configuration key
        } else {
            logger.warn("Invalid configuration key '%s' - only 'id' and 'param' are allowed!", key, value);
            throw new BindingConfigParseException("Invalid configuration key '" + key + "'");
        }
    }

    if (config.getDeviceId() == null) {
        throw new BindingConfigParseException("Invalid configuration: id is missing!");
    }
    if (config.getDeviceParam() == null) {
        throw new BindingConfigParseException("Invalid configuration: param is missing!");
    }

    logger.info("Adding item {} with {}", item.getName(), config.toString());
    items.put(item.getName(), item);

    itemMapById.put(config.getDeviceId(), item);
    itemMapByIdAndParam.put(config.getDeviceId(), config.getDeviceParam(), item);

    addBindingConfig(item, config);
    this.context.setBindingChanged(true);
}