Adam Heath wrote:
Adrian Crum wrote:
FlexibleStringExpander fse =
FlexibleStringExpander.getInstance("someExpression");
if (fse != null) {
  // some code
}

This was always broken.  Type foo = new Type();  foo will *never* be
null, period.  There are existing places in the code where this new
Type() compared to null takes place, unrelated to FSE.

I was trying to provide a simplified example. You are correct - the simplified example would never work to begin with. What the simplified example might really look like:

protected FlexibleStringExpander description = null;
...
public MyClass(String expression) {
  if (expression != null) {
    description = FlexibleStringExpander.getInstance(expression);
  }
}
...
public String getDescription(Map context) {
  if (description != null) {
    return description.expandString(context);
  }
  ...
}

-Adrian

Reply via email to