Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
In AbstractComposite, do the correct thing with add() or set() is cal…
Browse files Browse the repository at this point in the history
…led with a Component object
  • Loading branch information
edanuff committed Apr 4, 2011
1 parent e3b4b8c commit 0d40043
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ public boolean addAll(int i, Collection<? extends Object> c) {
@Override
public void add(int index, Object element) {
serialized = null;

if (element instanceof Component) {
components.add((Component<?>) element);
return;
}

element = mapIfNumber(element);
Serializer s = serializerForPosition(index);
if (s == null) {
Expand Down Expand Up @@ -561,6 +567,15 @@ public <T> AbstractComposite setComponent(int index, T value,
@Override
public Object set(int index, Object element) {
serialized = null;

if (element instanceof Component) {
Component prev = components.set(index, (Component<?>) element);
if (prev != null) {
return prev.getValue();
}
return null;
}

element = mapIfNumber(element);
Serializer s = serializerForPosition(index);
if (s == null) {
Expand Down

0 comments on commit 0d40043

Please sign in to comment.