in impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java [293:348]
public final void add(int index, Property p, Object value)
{
Iterator iterator = delegateProperties.iterator();
if (index == 0)
switch (insert(iterator, p, value))
{
case 0:
return;
case 1:
throw new IndexOutOfBoundsException();
default: // 2
throw new IllegalArgumentException();
}
while (iterator.hasNext())
{
Property property = (Property)iterator.next();
if (dataObject.isSet(property))
if (isSequenceProperty(property))
{
Sequence sequence = (Sequence)dataObject.get(property);
int size = sequence.size();
if (index < size)
{
sequence.add(index, p, value);
return;
}
index -= size;
if (index != 0)
continue;
if (insert(iterator, p, value) != 0)
/*assert */sequence.add(p, value);
return;
} // sequence(property)
else if (property.isMany())
{
List values = dataObject.getList(property);
int size = values.size();
if (index < size)
{
values.add(index, value);
return;
}
index -= size;
if (index == 0 && property == p)
{
values.add(value);
return;
}
}
else if (index == 0)
throw new IllegalArgumentException();
else
--index;
}
throw new IndexOutOfBoundsException();
}