Replace the nullable annotations with guava's Optional class.
- Lenguaje dominante
- Java
- Estrellas
- 102
- Forks
- 18
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
### 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));
}
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Comienza con com.sk89q.intake.argument.Namespace y revisa sus métodos get(Object) y get(Class) junto con la documentación enlazada de Guava Optional. Busca anotaciones nullable en el proyecto y determina qué APIs deben reemplazarse; se considera terminado cuando las anotaciones nullable se hayan reemplazado de forma coherente por el uso de Optional y el comportamiento afectado siga cubierto por las pruebas existentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- java
- Área
- cli
- Tipo de issue
- Refactorización
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100