class Expression {

    public static Expression of(String value) {
        if (!Strings.isNullOrEmpty(value) && value.trim().length() != 0) {
            if (value.contains(EXPRESSION_START) && value.indexOf(EXPRESSION_END) > 1) {
                int init = value.indexOf(EXPRESSION_START);
                int end = value.indexOf(EXPRESSION_END);
                String token = value.substring(init + 2, end);
                String prefix = null;
                String suffix = null;
                if (init > 0) {
                    prefix = value.substring(0, init);
                }
                if (end < value.length() - 1) {
                    suffix = value.substring(end + 1);
                }
                int idx = token.indexOf(":");
                String defaultValue = null;
                if (idx != -1) {
                    defaultValue = token.substring(idx + 1, token.length());
                    token = token.substring(0, idx);
                }
                return new Expression(prefix, token, defaultValue, suffix);
            } else {
                throw new IllegalArgumentException(
                        "Illegal expression \"" + value + "\": Please use the pattern ${key[:default-value]}");
            }
        }
        throw new IllegalArgumentException("Empty expression: Please use the pattern ${key[:default-value]}");
    }

    private  Expression(String prefix, String key, String defaultValue, String suffix);

}