private static <T> Parceler<T> getParcelerForClass(Class<T> clazz) { @SuppressWarnings("unchecked") Parceler<T> parceler = (com.workday.postman.parceler.Parceler<T>) parcelerMap.get(clazz); if (parceler == null) { String name = ConcreteTypeNames.constructClassName(clazz, Names.PARCELER_SUFFIX); try { @SuppressWarnings("unchecked") Parceler<T> newParceler = (Parceler<T>) Class.forName(name).newInstance(); parceler = newParceler; } catch (InstantiationException | IllegalAccessException e) { String message = "Postman experienced an internal error. Please report this issue."; throw new PostmanException(message, e); } catch (ClassNotFoundException e) { String message = String.format( "No %s was found for class %s. Check that (1) you annotated the class " + "with @%s, (2) the Postman processor ran, and (3) ProGuard did " + "not remove the Parcelers.", Parceler.class.getSimpleName(), clazz.getCanonicalName(), Parceled.class.getSimpleName()); throw new PostmanException(message, e); } parcelerMap.put(clazz, parceler); } return parceler; }
private static <T> Parceler<T> getParcelerForClass(Class<T> clazz) { @SuppressWarnings("unchecked") Parceler<T> parceler = (com.workday.postman.parceler.Parceler<T>) parcelerMap.get(clazz); if (parceler == null) { String name = ConcreteTypeNames.constructClassName(clazz, Names.PARCELER_SUFFIX); try { @SuppressWarnings("unchecked") Parceler<T> newParceler = (Parceler<T>) Class.forName(name).newInstance(); parceler = newParceler; } catch (InstantiationException | IllegalAccessException e) { String message = "Postman experienced an internal error. Please report this issue."; throw new PostmanException(message, e); } catch (ClassNotFoundException e) { String message = String.format( "No %s was found for class %s. Check that (1) you annotated the class " + "with @%s, (2) the Postman processor ran, and (3) ProGuard did " + "not remove the Parcelers.", Parceler.class.getSimpleName(), clazz.getCanonicalName(), Parceled.class.getSimpleName()); throw new PostmanException(message, e); } parcelerMap.put(clazz, parceler); } return parceler; }