{"record":{"id":"f6812148f3230008","repo":"gyf-dev/ImmersionBar","slug":"tag","errorCode":null,"errorMessage":"tag不能为空","messagePattern":"tag不能为空","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java","lineNumber":4402,"sourceCode":"     *\n     * @return the immersion bar\n     */\n    public ImmersionBar reset() {\n        mBarParams = createDefaultBarParams();\n        mFitsStatusBarType = FLAG_FITS_DEFAULT;\n        return this;\n    }\n\n    /**\n     * 给某个页面设置tag来标识这页bar的属性.\n     * Add tag bar tag.\n     *\n     * @param tag the tag\n     * @return the bar tag\n     */\n    public ImmersionBar addTag(String tag) {\n        if (isEmpty(tag)) {\n            throw new IllegalArgumentException(\"tag不能为空\");\n        }\n        BarParams barParams = mBarParams.clone();\n        mTagMap.put(tag, barParams);\n        return this;\n    }\n\n    /**\n     * 根据tag恢复到某次调用时的参数\n     * Recover immersion bar.\n     *\n     * @param tag the tag\n     * @return the immersion bar\n     */\n    public ImmersionBar getTag(String tag) {\n        if (isEmpty(tag)) {\n            throw new IllegalArgumentException(\"tag不能为空\");\n        }\n        BarParams barParams = mTagMap.get(tag);","sourceCodeStart":4384,"sourceCodeEnd":4420,"githubUrl":"https://github.com/gyf-dev/ImmersionBar/blob/8cac10cd83d809eac54f42b37f92340c4a25c4ac/immersionbar/src/main/java/com/gyf/immersionbar/ImmersionBar.java#L4384-L4420","documentation":"addTag stores a snapshot of current BarParams under a String tag for later restoration. Because the tag is the lookup key in mTagMap, an empty/null tag is rejected with IllegalArgumentException(\"tag不能为空\") (\"tag cannot be empty\").","triggerScenarios":"Calling bar.addTag(null) or bar.addTag(\"\") or a whitespace-only string (isEmpty check).","commonSituations":"Tag sourced from an unconfigured constant/BuildConfig field; tag read from a resource or intent extra that is missing; string interpolation producing an empty value.","solutions":["Pass a non-empty literal or constant tag","Validate the tag source (extra/config value) before calling addTag","Use a guaranteed default like \"default\" when the dynamic value is missing"],"exampleFix":"// before\nbar.addTag(getIntent().getStringExtra(\"theme\")); // may be null\n// after\nString theme = getIntent().getStringExtra(\"theme\");\nif (theme != null && !theme.trim().isEmpty()) {\n    bar.addTag(theme);\n}","handlingStrategy":"validation","validationCode":"if (tag != null && !tag.trim().isEmpty()) { bar.addTag(tag); }","typeGuard":"boolean validTag(String t) { return t != null && !t.trim().isEmpty(); }","tryCatchPattern":"try { bar.addTag(tag); } catch (IllegalArgumentException e) { Log.e(TAG, \"empty tag\", e); }","preventionTips":["Use string constants for tags instead of dynamic values","Validate intent extras/resources before use as tags","Provide a default tag value"],"tags":["android","null-check","argument-validation","empty-string"],"backgroundTag":"empty-required-field","analyzedSha":"8cac10cd83d809eac54f42b37f92340c4a25c4ac","analyzedAt":"2026-09-08T11:52:01.757Z","contentChangedAt":"2026-09-08T11:52:01.757Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}