protected void encodeScript(FacesContext context, InputMask component) throws IOException {
        String mask = component.getMask();
        WidgetBuilder wb = getWidgetBuilder(context);
        wb.init("InputMask", component);

        if (mask != null) {
            // autoclear must be false when using optional mask
            boolean autoClear = component.isAutoClear();
            if (isMaskOptional(mask)) {
                autoClear = false;
            }
            wb.attr("mask", mask)
                .attr("placeholder", component.getSlotChar(), "_")
                .attr("autoClear", autoClear, true)
                .attr("showMaskOnFocus", component.isShowMaskOnFocus(), true)
                .attr("showMaskOnHover", component.isShowMaskOnHover(), true);
        }

        wb.finish();
    }
Checks if the given mask string contains any optional mask characters.
In this context, an optional mask character is defined as either '[' or ']'.

@param mask the mask string to check
@return {@code true} if the mask contains either '[' or ']'; {@code false} otherwise
primefaces/src/main/java/org/primefaces/component/inputmask/InputMaskRenderer.java