2323import java .lang .annotation .Annotation ;
2424import java .util .Optional ;
2525
26+ import com .arangodb .ArangoDBException ;
2627import org .springframework .beans .BeansException ;
2728import org .springframework .beans .factory .ObjectProvider ;
2829import org .springframework .context .ApplicationContext ;
@@ -45,32 +46,39 @@ public class DefaultResolverFactory implements ResolverFactory, ApplicationConte
4546 @ SuppressWarnings ("unchecked" )
4647 @ Override
4748 public <A extends Annotation > Optional <ReferenceResolver <A >> getReferenceResolver (final A annotation ) {
48- ReferenceResolver <A > resolver = null ;
49- if (annotation instanceof Ref ) {
50- resolver = (ReferenceResolver <A >) new RefResolver (template .getObject (), transactionBridge .getIfUnique ());
49+ try {
50+ if (annotation instanceof Ref ) {
51+ return Optional .of ((ReferenceResolver <A >) new RefResolver (template .getObject (), transactionBridge .getIfUnique ()));
52+ }
53+ } catch (final Exception e ) {
54+ throw new ArangoDBException (e );
5155 }
52- return Optional .ofNullable ( resolver );
56+ return Optional .empty ( );
5357 }
5458
5559 @ SuppressWarnings ("unchecked" )
5660 @ Override
5761 public <A extends Annotation > Optional <RelationResolver <A >> getRelationResolver (final A annotation ,
5862 final Class <? extends Annotation > collectionType ) {
5963 RelationResolver <A > resolver = null ;
60- if (annotation instanceof From ) {
61- if (collectionType == Edge .class ) {
62- resolver = (RelationResolver <A >) new EdgeFromResolver (template .getObject (), transactionBridge .getIfUnique ());
63- } else if (collectionType == Document .class ) {
64- resolver = (RelationResolver <A >) new DocumentFromResolver (template .getObject (), transactionBridge .getIfUnique ());
65- }
66- } else if (annotation instanceof To ) {
67- if (collectionType == Edge .class ) {
68- resolver = (RelationResolver <A >) new EdgeToResolver (template .getObject (), transactionBridge .getIfUnique ());
69- } else if (collectionType == Document .class ) {
70- resolver = (RelationResolver <A >) new DocumentToResolver (template .getObject (), transactionBridge .getIfUnique ());
64+ try {
65+ if (annotation instanceof From ) {
66+ if (collectionType == Edge .class ) {
67+ resolver = (RelationResolver <A >) new EdgeFromResolver (template .getObject (), null );
68+ } else if (collectionType == Document .class ) {
69+ resolver = (RelationResolver <A >) new DocumentFromResolver (template .getObject (), null );
70+ }
71+ } else if (annotation instanceof To ) {
72+ if (collectionType == Edge .class ) {
73+ resolver = (RelationResolver <A >) new EdgeToResolver (template .getObject (), null );
74+ } else if (collectionType == Document .class ) {
75+ resolver = (RelationResolver <A >) new DocumentToResolver (template .getObject (), null );
76+ }
77+ } else if (annotation instanceof Relations ) {
78+ resolver = (RelationResolver <A >) new RelationsResolver (template .getObject (), null );
7179 }
72- } else if ( annotation instanceof Relations ) {
73- resolver = ( RelationResolver < A >) new RelationsResolver ( template . getObject (), transactionBridge . getIfUnique () );
80+ } catch ( final Exception e ) {
81+ throw new ArangoDBException ( e );
7482 }
7583 return Optional .ofNullable (resolver );
7684 }
0 commit comments