Project: Eclipse_Platform_UI
Bug 137877 [DataBinding] StructuredViewerObservableValue javadoc and code cleanup
Reported: 2006-04-21 01:03:42 | Status: verified fixed

I started looking at this class to see what it was doing and noticed a potential problem if anyone was to extend this class and this snowballed into adding javadoc, cleaning up the code a bit, and writing tests. Changes made: * documented doGetValue() and the constructor to warn of subclassing issues. see explanation below... * changed doGetValue() from public to protected. I'm assuming since this is a template method it is only meant for the eyes of subclasses and other package classes. * removed the 'attribute' parameter from the constructor because the constructor wouldn't allow but one value for attribute and would throw an IAE if it wasn't correct. Every method was then checking this variable for the same value and because it was only set at construction and only one value was allowed it seemed redundant. * removed 'attribute' from the class and from every method because of the removal of it from the constructor. * added validation for constructor parameters doGetValue() is public and if someone was to extend this class and override doGetValue() this method would get invoked before their subclass was fully initialized because their constructor would not have ran yet. Because this class extends from AbstractObservableValue and doGetValue() is declared as protected it didn't seem like much could be done about changing this so I ended up documenting it thoroughly in the constructor javadoc and the javadoc for doGetValue(). The constructor signature change and the validation the constructor parameter are both nonpassive changes. I also was wanting to rename the class to StructuredViewerSingleSelectionObservableValue but didn't do so in order to be able to provide a patch that allowed for the easy viewing of the changes made. Because of the constructor change I had to change ViewersObservableFactory as well when constructing the object.

Files changed in fix:
bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValue.java bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/internal/viewers/StructuredViewerObservableValue.java bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/viewers/ViewersObservableFactory.java tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/internal/viewers/SelectionProviderSingleSelectionObservableValueTest.java tests/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/internal/databinding/provisional/viewers/ViewersObservableFactoryTest.java