class DiagramLoader {

    @SuppressWarnings("unchecked")
    public void loadByPath(final Path path,
                           final ServiceCallback<Diagram> callback) {
        clientDiagramServices.getByPath(path,
                                        new ServiceCallback<Diagram<Graph, Metadata>>() {
                                            @Override
                                            public void onSuccess(final Diagram<Graph, Metadata> diagram) {
                                                loadPreferences(diagram,
                                                                prefs -> callback.onSuccess(diagram),
                                                                error -> callback.onError(new ClientRuntimeError(error)));
                                            }

                                            @Override
                                            public void onError(final ClientRuntimeError error) {
                                                callback.onError(error);
                                            }
                                        });
    }

    @Inject public  DiagramLoader(final ClientDiagramService clientDiagramServices,
                         final StunnerPreferencesRegistryLoader preferencesRegistryLoader);

}