protected void throwInvalidContextType ( final String methodName , final BsonContextType actualContextType , final BsonContextType ... validContextTypes ) { String validContextTypesString = StringUtils . join ( " or " , asList ( validContextTypes ) ) ; String message = format ( "%s can only be called when ContextType is %s, not when ContextType is %s." , methodName , validContextTypesString , actualContextType ) ; throw new BsonInvalidOperationException ( message ) ; }
Throws an InvalidOperationException when the method called is not valid for the current ContextType .