eclipse-platform / eclipse-platform/eclipse.platform
Enhance ResourceAttributes: Use Optional in fromFile() and Improve set() Method
- Vorherrschende Sprache
- Java
- Sterne
- 165
- Forks
- 174
- Ø Merge
- 2 T. 8 Std.
- Gemergte PRs (30 T.)
- 22
Beschreibung
### Description
Enhance `ResourceAttributes.java`:
- `fromFile(java.io.File file)` now returns `Optional` instead of a nullable object.
- Improved `set(int mask, boolean value)` method for better readability and maintainability.
- Updated Javadoc comments to reflect the new behavior.
---
### Expected behavior
- Returning `Optional` makes the API safer by avoiding potential `null` references.
- The `set` method becomes clearer and more robust.
- Updated documentation helps future developers understand the new behavior precisely.
---
### Benefits
- Increases null-safety and code clarity.
- Improves API usability and developer experience.
- Aligns with modern Java best practices.
---
### How to reproduce (Current Behavior)
- `ResourceAttributes.fromFile(file)` returns `null` on failure.
### How to reproduce (After Improvement)
- `ResourceAttributes.fromFile(file)` returns `Optional.empty()` on failure, making `null` checks unnecessary.
---
### Additional context
- All modifications are isolated to `org.eclipse.core.resources.ResourceAttributes`.
- No breaking change for existing code unless `fromFile()` is used without null checking.
---
### Environment
- Java version: 17
- Eclipse Platform repository: https://github.com/eclipse-platform/eclipse.platform
- Module: `org.eclipse.core.resources`
- Files involved: `ResourceAttributes.java`
---
### Community
- [x] I understand suggesting an enhancement doesn't mandate anyone to implement it. Other contributors may consider this suggestion, or not, at their own convenience. The most efficient way to get it fixed is that I implement it myself and contribute it back as a good quality patch to the project.
Beitragsleitfaden
Rechercherichtung
Beginne mit org.eclipse.core.resources.ResourceAttributes.java im Modul org.eclipse.core.resources. Überprüfe fromFile(), set(int mask, boolean value) und deren Javadocs; suche anschließend nach Aufrufern von fromFile(), um die Auswirkungen auf die API zu verstehen. Führe die vorhandenen Tests des Moduls aus und verifiziere, dass Fehler Optional.empty() zurückgeben und die aktualisierte Dokumentation dem Verhalten entspricht.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100