Skip to content
Back to skills

Refactor Java Null Checks Using Spring Objectutils

ASecurity

Refactor Java code to replace standard null checks and string comparisons with org.springframework.util.ObjectUtils utility methods for safer and cleaner code.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
ai-agentsjavaspringrefactoring

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill refactor-java-null-checks-using-spring-objectutils --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Refactor Java Null Checks Using Spring Objectutils?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Refactor Java Null Checks Using Spring Objectutils
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-refactor-java-null-checks-using-spring-objectutils/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-refactor-java-null-checks-using-spring-objectutils)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "003ea093-8549-4cde-88bb-b4e4a31d9961"
name: "Refactor Java null checks using Spring ObjectUtils"
description: "Refactor Java code to replace standard null checks and string comparisons with org.springframework.util.ObjectUtils utility methods for safer and cleaner code."
version: "0.1.0"
tags:
  - "java"
  - "spring"
  - "refactoring"
  - "null-check"
  - "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"
---

# 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
1. **Import Statement**: Ensure `import org.springframework.util.ObjectUtils;` is included in the code.
2. **Null Checks**: Replace standard `!= null` checks with `ObjectUtils.isEmpty(obj)` to check for null or empty objects. To check for non-null/non-empty, use `!ObjectUtils.isEmpty(obj)`.
3. **String Comparison**: Replace `str.equals("value")` or `str != null && str.equals("value")` with `ObjectUtils.nullSafeEquals(str, "value")`.
4. **Logging**: Use `ObjectUtils.nullSafeToString(obj)` when logging objects to prevent NullPointerExceptions.
5. **Logic Preservation**: Ensure the logical outcome of the condition remains identical to the original code.

# Anti-Patterns
- Do not use `ObjectUtils.isNotEmpty` as it is not a valid method in `org.springframework.util.ObjectUtils` (use `!ObjectUtils.isEmpty(...)` instead).
- Do not leave manual `!= null` checks if `ObjectUtils` can be applied.

## Triggers

- use ObjectUtils for null check
- refactor code to use org.springframework.util.ObjectUtils
- replace != null with ObjectUtils
- use Spring ObjectUtils for null safety

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.