eclipse-platform / eclipse-platform/eclipse.platform

Enhance ResourceAttributes: Use Optional in fromFile() and Improve set() Method

Aperta
#1,801 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Java
Stelle
165
Fork
174
Merge medio
2g 8h
PR unite (30g)
22

Descrizione

### 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia da org.eclipse.core.resources.ResourceAttributes.java nel modulo org.eclipse.core.resources. Esamina fromFile(), set(int mask, boolean value) e i relativi Javadocs, quindi cerca i chiamanti di fromFile() per comprendere l’impatto sull’API. Esegui i test esistenti del modulo e verifica che gli errori restituiscano Optional.empty() e che la documentazione aggiornata corrisponda al comportamento.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.