@SuppressWarnings("unchecked") private <AdapterType> AdapterType getAdapter( final Comment comment, final Class<AdapterType> type) { if (POST_CLASS == type || MUTABLE_POST_CLASS == type) { return (AdapterType) new PostImpl( comment, comment.getResource().getResourceResolver(), eventAdmin, notificationManager, workflowService); } return null; }