public boolean canAcceptChild ( Class < ? extends ElementBase > childClass ) { if ( ! canAcceptChild ( ) ) { return false ; } Cardinality cardinality = allowedChildClasses . getCardinality ( getClass ( ) , childClass ) ; int max = cardinality . getMaxOccurrences ( ) ; if ( max == 0 ) { rejectReason = getDisplayName ( ) + " does not accept " + childClass . getSimpleName ( ) + " as a child." ; } else if ( max != Integer . MAX_VALUE && getChildCount ( cardinality . getTargetClass ( ) ) >= max ) { rejectReason = getDisplayName ( ) + " cannot accept more than " + max + " of " + cardinality . getTargetClass ( ) . getSimpleName ( ) + "." ; } return rejectReason == null ; }
Returns true if this element may accept a child of the specified class . Updates the reject reason with the result .