Error checking in one place and add TODO about verifying if we need to require TermItem.
@@ -50,6 +50,7 @@ public class SameElementItem extends NonReducibleCompositeItem {
@Override
protected void adding(Item item) {
super.adding(item);
+ //TODO See if we can require only SimpleIndexedItem instead of TermItem
Validator.ensureInstanceOf("Child item", item, TermItem.class);
TermItem asTerm = (TermItem) item;
Validator.ensureNonEmpty("Struct fieldname", asTerm.getIndexName());
@@ -58,7 +59,7 @@ public class SameElementItem extends NonReducibleCompositeItem {
@Override
public Optional<Item> extractSingleChild() {
- if (getItemCount() == 1 && getItem(0) instanceof SimpleIndexedItem) {
+ if (getItemCount() == 1) {
SimpleIndexedItem child = (SimpleIndexedItem)getItem(0);
child.setIndexName(getFieldName() + "." + child.getIndexName());
return Optional.of(child);
