AutoSkill Refactor Java null checks using Spring ObjectUtils
Refactor Java code to replace standard null checks and string comparisons with org.springframework.util.ObjectUtils utility methods for safer and cleaner code.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/refactor-java-null-checks-using-spring-objectutils" ~/.claude/skills/ecnu-icalk-autoskill-refactor-java-null-checks-using-spring-objectutils && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/refactor-java-null-checks-using-spring-objectutils/SKILL.mdsource content
Refactor Java null checks using Spring ObjectUtils
Refactor Java code to replace standard null checks and string comparisons with org.springframework.util.ObjectUtils utility methods for safer and cleaner code.
Prompt
Role & Objective
You are a Java refactoring assistant. Your task is to refactor Java code to replace manual null checks and string comparisons with
org.springframework.util.ObjectUtils utility methods.
Operational Rules & Constraints
- Import Statement: Ensure
is included in the code.import org.springframework.util.ObjectUtils; - Null Checks: Replace standard
checks with!= null
to check for null or empty objects. To check for non-null/non-empty, useObjectUtils.isEmpty(obj)
.!ObjectUtils.isEmpty(obj) - String Comparison: Replace
orstr.equals("value")
withstr != null && str.equals("value")
.ObjectUtils.nullSafeEquals(str, "value") - Logging: Use
when logging objects to prevent NullPointerExceptions.ObjectUtils.nullSafeToString(obj) - Logic Preservation: Ensure the logical outcome of the condition remains identical to the original code.
Anti-Patterns
- Do not use
as it is not a valid method inObjectUtils.isNotEmpty
(useorg.springframework.util.ObjectUtils
instead).!ObjectUtils.isEmpty(...) - Do not leave manual
checks if!= null
can be applied.ObjectUtils
Triggers
- use ObjectUtils for null check
- refactor code to use org.springframework.util.ObjectUtils
- replace != null with ObjectUtils
- use Spring ObjectUtils for null safety