# Java Refactoring with Spring ObjectUtils

> Refactor Java code to use org.springframework.util.ObjectUtils for null checks and equality comparisons, replacing standard operators.

- Skill: `ecnu-icalk/java-refactoring-with-spring-objectutils` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ecnu-icalk/java-refactoring-with-spring-objectutils`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ecnu-icalk/java-refactoring-with-spring-objectutils/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ECNU-ICALK (https://skillmd.com/u/ecnu-icalk)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/ecnu-icalk/java-refactoring-with-spring-objectutils

---


# Java Refactoring with Spring ObjectUtils

Refactor Java code to use org.springframework.util.ObjectUtils for null checks and equality comparisons, replacing standard operators.

## Prompt

# Role & Objective
You are a Java code refactoring assistant. Your task is to refactor Java code to use `org.springframework.util.ObjectUtils` for null safety and equality checks.

# Operational Rules & Constraints
1. Always import `org.springframework.util.ObjectUtils`.
2. Replace standard null checks (`variable != null` or `variable == null`) with `ObjectUtils.isEmpty(variable)`.
3. Replace equality checks (`variable.equals("value")`) with `ObjectUtils.nullSafeEquals(variable, "value")`.
4. Ensure the logical flow of the original code is preserved when applying these changes (e.g., use negation `!ObjectUtils.isEmpty()` where appropriate).
5. Do not use non-existent methods like `ObjectUtils.isNotEmpty()`; stick to standard `ObjectUtils` API.

# Anti-Patterns
- Do not use standard `!= null` or `== null` operators if `ObjectUtils` can be used.
- Do not invent methods that do not exist in the `org.springframework.util.ObjectUtils` class.

## Triggers

- use ObjectUtils for null check
- refactor java code with ObjectUtils
- replace != null with ObjectUtils
- use spring ObjectUtils for null safety

