Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:APIJSON APIJSON Warning Deprecated StringUtil Legacy Aliases

From Leeroopedia
Knowledge Sources
Domains Deprecation, String_Processing
Last Updated 2026-10-11 00:00 GMT

Overview

Warning: StringUtil contains 17 @Deprecated legacy alias methods that should not be used in new code — use the shorter replacement methods instead.

Description

The StringUtil class in apijson.StringUtil carries a set of legacy method names marked @Deprecated with FIXME comments instructing callers to use the shorter, canonical replacements. Each deprecated method is a trivial delegate — it forwards directly to the replacement without any additional logic. They exist purely for backward compatibility with older callers.

The deprecated families are:

Deprecated Method(s) Replacement FIXME Comment
getCurrentString() cur() 改用 cur
getString(Object) getString(CharSequence) getString(String) getString(Object[]) getString(Object[], boolean) getString(Object[], String) getString(Object[], String, boolean) get(...) (same overloads) 用 get 替代
getTrimedString(Object) getTrimedString(CharSequence) getTrimedString(String) trim(...) (same overloads) 用 trim 替代
getNoBlankString(Object) getNoBlankString(CharSequence) getNoBlankString(String) noBlank(...) (same overloads) 用 noBlank 替代
getLength(Object, boolean) getLength(CharSequence, boolean) getLength(String, boolean) length(...) (same overloads) 用 length 替代

Usage

Use this heuristic when auditing or writing code that imports apijson.StringUtil. Replace any call to a deprecated method with its canonical replacement listed above. Do not introduce new calls to the deprecated methods.

The Insight (Rule of Thumb)

  • Action: Replace deprecated method calls with the canonical short-name equivalents.
  • Value mapping:
    • getCurrentString() → cur()
    • getString(...) → get(...)
    • getTrimedString(...) → trim(...)
    • getNoBlankString(...) → noBlank(...)
    • getLength(...) → length(...)
  • Trade-off: No functional difference — the deprecated methods are pure delegates. The benefit is cleaner code and avoiding compiler deprecation warnings.
  • Compatibility: All deprecated methods remain functional for backward compatibility but may be removed in future versions.

Reasoning

The FIXME comments in the source (e.g., "FIXME 用 get 替代" meaning "replace with get") confirm these are intentional deprecations, not accidental. The README-extend.md file also documents the @Deprecated pattern (line 82: "第二种: @Deprecated 即将弃用,请使用第一种" — "second form: @Deprecated, will be removed, please use the first form"). The deprecated methods add no behavior beyond what the replacements provide — they are thin wrappers that call the canonical methods and return the result.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment