public static Map < String , ClassNode > getAssocationMap ( ClassNode classNode , String associationType ) { PropertyNode property = classNode . getProperty ( associationType ) ; Map < String , ClassNode > associationMap = new HashMap < String , ClassNode > ( ) ; if ( property != null && property . isStatic ( ) ) { Expression e = property . getInitialExpression ( ) ; if ( e instanceof MapExpression ) { MapExpression me = ( MapExpression ) e ; for ( MapEntryExpression mee : me . getMapEntryExpressions ( ) ) { String key = mee . getKeyExpression ( ) . getText ( ) ; Expression valueExpression = mee . getValueExpression ( ) ; if ( valueExpression instanceof ClassExpression ) { associationMap . put ( key , valueExpression . getType ( ) ) ; } } } } return associationMap ; }
Returns a map containing the names and types of the given association type . eg . GrailsDomainClassProperty . HAS_MANY