private Action annotationToAction ( Siren4JAction actionAnno , EntityContext context ) throws Siren4JException { ActionBuilder builder = ActionBuilder . newInstance ( ) ; builder . setName ( actionAnno . name ( ) ) . setHref ( actionAnno . href ( ) ) . setMethod ( actionAnno . method ( ) ) ; if ( ArrayUtils . isNotEmpty ( actionAnno . actionClass ( ) ) ) { builder . setComponentClass ( actionAnno . actionClass ( ) ) ; } if ( StringUtils . isNotBlank ( actionAnno . title ( ) ) ) { builder . setTitle ( actionAnno . title ( ) ) ; } if ( StringUtils . isNotBlank ( actionAnno . type ( ) ) ) { builder . setType ( actionAnno . type ( ) ) ; } if ( ArrayUtils . isNotEmpty ( actionAnno . fields ( ) ) ) { for ( Siren4JActionField f : actionAnno . fields ( ) ) { builder . addField ( annotationToField ( f , context ) ) ; } } if ( ArrayUtils . isNotEmpty ( actionAnno . urlParams ( ) ) ) { for ( Siren4JActionField f : actionAnno . urlParams ( ) ) { builder . addUrlParam ( annotationToField ( f , context ) ) ; } } if ( ArrayUtils . isNotEmpty ( actionAnno . headers ( ) ) ) { for ( Siren4JActionField f : actionAnno . headers ( ) ) { builder . addHeader ( annotationToField ( f , context ) ) ; } } if ( ArrayUtils . isNotEmpty ( actionAnno . metaData ( ) ) ) { Map < String , String > metaData = new HashMap ( ) ; for ( Siren4JMetaData mdAnno : actionAnno . metaData ( ) ) { metaData . put ( mdAnno . key ( ) , handleTokenReplacement ( mdAnno . value ( ) , context ) ) ; } builder . setMetaData ( metaData ) ; } return builder . build ( ) ; }
Convert an action annotation to an actual action . The href will not be resolved in the instantiated action this will need to be post processed .