@SuppressWarnings("unchecked") @Override public String print(Object object, Locale locale) { if (object == null) { return ""; } // note: getClassWithoutInitializingProxy expects a non null object // _HACK_ as we depend on hibernate here. DiscoverablePrinter printer = printers.get(getClassWithoutInitializingProxy(object)); return printer == null ? object.toString() : printer.print(object, locale); }
@Inject void buildCache(List<DiscoverablePrinter> registredPrinters) { for (DiscoverablePrinter printer : registredPrinters) { printers.put(printer.getTarget(), printer); } }