Skip to content

Commit 1ddc51e

Browse files
committed
Revert "Add empty option for not-required parameter in Widget"
This reverts commit 45ab6cf. This will require a revision of how the ObjectPool is handled in widgets, as it currently breaks the javadoc contract (in that if a null value is added to the ObjectPool, the item value is forced to be null).
1 parent 71ad4d5 commit 1ddc51e

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/main/java/org/scijava/widget/DefaultWidgetModel.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public DefaultWidgetModel(final Context context, final InputPanel<?, ?> inputPan
8787
this.module = module;
8888
this.item = item;
8989
this.objectPool = objectPool;
90-
if (!item.isRequired())
91-
this.objectPool.add(0, null);
9290
convertedObjects = new WeakHashMap<Object, Object>();
9391

9492
if (item.getValue(module) == null) {
@@ -317,10 +315,8 @@ private Object ensureValidObject(final Object value) {
317315

318316
/** Ensures the value is on the given list. */
319317
private Object ensureValid(final Object value, final List<?> list) {
320-
if (value == null)
321-
return list.contains(null);
322318
for (final Object o : list) {
323-
if (value.equals(o)) return value; // value is valid
319+
if (o.equals(value)) return value; // value is valid
324320
// check if value was converted and cached
325321
final Object convertedValue = convertedObjects.get(o);
326322
if (convertedValue != null && value.equals(convertedValue)) {

0 commit comments

Comments
 (0)