This method's contract is a bit under-specified in terms of expected
implementation behaviour and as to how nulls are treated. Improve that
a bit.
JIRA: YANGTOOLS-1214
Change-Id: Ie2043d8af803376077b10bba6a53a1959c0a6ed3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
return (existing = effectiveInstance) != null ? existing : loadEffective();
}
- private E loadEffective() {
+ private @NonNull E loadEffective() {
// Creating an effective statement does not strictly require a declared instance -- there are statements like
// 'input', which are implicitly defined.
// Our implementation design makes an invariant assumption that buildDeclared() has been called by the time
}
/**
- * Builds {@link EffectiveStatement} for statement context.
+ * Return the {@link EffectiveStatement} for statement context, creating it if required. Implementations of this
+ * method are required to memoize the returned object, so that subsequent invocation return the same object.
+ *
+ * <p>
+ * If {@link #isSupportedToBuildEffective()} returns {@code false}, this method's behaviour is undefined.
+ *
+ * @return Effective statement instance.
*/
- E buildEffective();
+ @NonNull E buildEffective();
boolean isSupportedToBuildEffective();