use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.
the class MethodRef method get.
@Nullable
Method get() {
if (this.methodRef == null) {
return null;
}
Method method = this.methodRef.get();
if (method == null) {
method = find(this.typeRef.get(), this.signature);
if (method == null) {
this.signature = null;
this.methodRef = null;
this.typeRef = null;
} else {
this.methodRef = new SoftReference<>(method);
}
}
return isPackageAccessible(method.getDeclaringClass()) ? method : null;
}
use of org.checkerframework.checker.nullness.qual.Nullable in project checker-framework by typetools.
the class PropertyDescriptor method getWriteMethod.
/**
* Gets the method that should be used to write the property value.
*
* @return The method that should be used to write the property value.
* May return null if the property can't be written.
*/
@Pure
@Nullable
public synchronized Method getWriteMethod() {
Method writeMethod = this.writeMethodRef.get();
if (writeMethod == null) {
Class<?> cls = getClass0();
if (cls == null || (writeMethodName == null && !this.writeMethodRef.isSet())) {
// The write method was explicitly set to null.
return null;
}
// We need the type to fetch the correct method.
Class<?> type = getPropertyType0();
if (type == null) {
try {
// Can't use getPropertyType since it will lead to recursive loop.
type = findPropertyType(getReadMethod(), null);
setPropertyType(type);
} catch (IntrospectionException ex) {
// to find the correct method.
return null;
}
}
if (writeMethodName == null) {
writeMethodName = Introspector.SET_PREFIX + getBaseName();
}
Class<?>[] args = (type == null) ? null : new Class<?>[] { type };
writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args);
if (writeMethod != null) {
if (!writeMethod.getReturnType().equals(void.class)) {
writeMethod = null;
}
}
try {
setWriteMethod(writeMethod);
} catch (IntrospectionException ex) {
// fall through
}
}
return writeMethod;
}
Aggregations