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);
    }
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);
    }
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.

@param methodName        The name of the method.
@param actualContextType The actual ContextType.
@param validContextTypes The valid ContextTypes.
@throws BsonInvalidOperationException when the method called is not valid for the current ContextType.
Throws an InvalidOperationException when the method called is not valid for the current ContextType .