private void handleEntityActions ( EntityBuilder builder , EntityContext context ) throws Siren4JException { Class < ? > clazz = context . getCurrentObject ( ) . getClass ( ) ; Map < String , Action > actions = new HashMap < String , Action > ( ) ; /* Caution!! Order matters when adding to the actions map */ Siren4JEntity entity = clazz . getAnnotation ( Siren4JEntity . class ) ; if ( entity != null && ArrayUtils . isNotEmpty ( entity . actions ( ) ) ) { for ( Siren4JAction a : entity . actions ( ) ) { if ( evaluateConditional ( a . condition ( ) , context ) ) { actions . put ( a . name ( ) , annotationToAction ( a , context ) ) ; } } } if ( context . getParentField ( ) != null ) { Siren4JSubEntity subentity = context . getParentField ( ) . getAnnotation ( Siren4JSubEntity . class ) ; if ( subentity != null && ArrayUtils . isNotEmpty ( subentity . actions ( ) ) ) { for ( Siren4JAction a : subentity . actions ( ) ) { if ( evaluateConditional ( a . condition ( ) , context ) ) { actions . put ( a . name ( ) , annotationToAction ( a , context ) ) ; } } } } Collection < Action > resourceLinks = context . getCurrentObject ( ) instanceof Resource ? ( ( Resource ) context . getCurrentObject ( ) ) . getEntityActions ( ) : null ; if ( resourceLinks != null ) { for ( Action a : resourceLinks ) { actions . put ( a . getName ( ) , a ) ; } } for ( Action a : actions . values ( ) ) { a . setHref ( resolveUri ( a . getHref ( ) , context , false ) ) ; builder . addAction ( a ) ; } }
Handles getting all entity actions both dynamically set and via annotations and merges them together overriding with the proper precedence order which is Dynamic > SubEntity > Entity . Href and uri s are resolved with the correct data bound in .