MicroSpaceNullValueExtractor.java
package org.microspace.specific;
import java.lang.reflect.Method;
import org.microspace.annotation.NullValue;
/**
* Used by primitive types.
*
* @author Gaspar Sinai - {@literal gaspar.sinai@microspace.org}
* @version 2016-06-26
*/
public class MicroSpaceNullValueExtractor implements NullValueExtractor {
public String getNullValue(Method getMethod) {
NullValue property = getMethod.getAnnotation(NullValue.class);
if (property == null) return null;
if (!getMethod.getReturnType().isPrimitive()) {
throw new IllegalArgumentException ("NullValue annotation is for primitive types.");
}
if (property.value()==null || NullValue.AUTO.equals (property.value())) return null;
return property.value();
}
}