public int getListFieldLength ( String fieldName ) { int ret = - 1 ; Object val = getFieldValue ( fieldName , true ) ; // internal if ( val instanceof List < ? > ) ret = ( ( List < ? > ) val ) . size ( ) ; else if ( val != null && val . getClass ( ) . isArray ( ) ) { ret = Array . getLength ( val ) ; } else { if ( ! getDomainObjectType ( ) . getFieldByName ( fieldName ) . isListOrArray ( ) ) throw new RuntimeException ( "field: [" + fieldName + "] is neither list nor array" ) ; if ( val == null ) throw new RuntimeException ( "list or array field: [" + fieldName + "] is null" ) ; } return ret ; }
Answer the length of a list field