boolean (@Nullable String value) { if (value == null || !value.startsWith("$")) return false; if (value.length() == 1) return true; final boolean expressionStarts = value.startsWith("${"); final boolean expressionEnds = value.endsWith("}"); if (expressionStarts && expressionEnds && value.length() == 3) return true; if (expressionStarts != expressionEnds) return true; if (expressionStarts && value.indexOf('{', 2) >= 2) return true; if (expressionEnds && value.indexOf('}') < value.length() - 1) return true; return false; }