Replace the nullable annotations with guava's Optional class.
- Langage dominant
- Java
- Étoiles
- 102
- Forks
- 18
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
### What's the point of Guava's Optional class?
Probably the single biggest disadvantage of null is that it's not obvious what it should mean in any given context: it doesn't have an illustrative name. It's not always obvious that null means "no value for this parameter" -- heck, as a return value, sometimes it means "error", or even "success" (!!), or simply "the correct answer is nothing". Optional is frequently the concept you actually mean when you make a variable nullable, but not always.
more: http://stackoverflow.com/questions/9561295/whats-the-point-of-guavas-optional-class
#### Optional class: http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Optional.html
Example in `com.sk89q.intake.argument.Namespace`
``` java
/**
* Returns the value specified by the given key.
*
* @param key The key
* @return The value, which may be null, including when the key doesn't exist
*/
public Optional get(Object key) {
if (!locals.containsKey(key)) Optional.absent();
return Optional.of(locals.get(key));
}
/**
* Get an object whose key will be the object's class.
*
* @param key The key
* @param The type of object
* @return The value
*/
@SuppressWarnings("unchecked")
public Optional get(Class key) {
if (!locals.containsKey(key)) Optional.absent();
return Optional.of((T)locals.get(key));
}
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez par com.sk89q.intake.argument.Namespace et examinez ses méthodes get(Object) et get(Class) ainsi que la documentation Guava Optional liée. Recherchez les annotations nullable dans le projet et déterminez quelles APIs doivent être remplacées ; le travail est terminé lorsque les annotations nullable ont été remplacées de manière cohérente par l’utilisation de Optional et que le comportement concerné reste couvert par les tests existants.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- cli
- Type d'issue
- Refactorisation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100