class CachingExpanderRegistry implements ExpanderRegistry {

  @Override
  public ExpressionExpander getExpander(Class<? extends ExpressionExpander> expanderClass) {
    return this.expanderMapCache.computeIfAbsent(expanderClass,
        type -> {
          try {
            return (ExpressionExpander) type.getDeclaredConstructor().newInstance();
          } catch (Exception ex) {
            throw new IllegalStateException("Error occurred creating custom expander instance "
                + "for type " + type.getSimpleName() + ".  "
                + "Could not create instance." + ex.getMessage(), ex);
          }
        });
  }

}