1 | if (collection.size() == 0)↵ | | 1 | if (collection.size() == 0)↵
|
2 | {↵ | | 2 | {↵
|
3 | return false;↵ | | 3 | return false;↵
|
4 | }↵ | | 4 | }↵
|
5 | boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);↵ | | 5 | boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature);↵
|
6 | @SuppressWarnings("unchecked") Collection<Entry> entryCollection = ↵ | | 6 | @SuppressWarnings("unchecked") Collection<Entry> entryCollection = ↵
|
7 | isFeatureMap ? ↵ | | 7 | isFeatureMap ? ↵
|
8 | (Collection<Entry>)collection :↵ | | 8 | (Collection<Entry>)collection :↵
|
9 | new BasicEList<Entry>(collection.size());↵ | | 9 | new BasicEList<Entry>(collection.size());↵
|
10 | if (isMany(feature))↵ | | 10 | if (isMany(feature))↵
|
11 | {↵ | | 11 | {↵
|
12 | if (feature.isUnique())↵ | | 12 | if (feature.isUnique())↵
|
13 | {↵ | | 13 | {↵
|
14 | for (Object object : collection)↵ | | 14 | for (Object object : collection)↵
|
15 | {↵ | | 15 | {↵
|
16 | if (!contains(feature, object))↵ | | 16 | if (!contains(feature, object))↵
|
17 | {↵ | | 17 | {↵
|
18 | Entry entry = createEntry(feature, object);↵ | | 18 | Entry entry = createEntry(feature, object);↵
|
19 | entryCollection.add(entry);↵ | | 19 | entryCollection.add(entry);↵
|
20 | }↵ | | 20 | }↵
|
21 | }↵ | | 21 | }↵
|
22 | }↵ | | 22 | }↵
|
23 | else if (!isFeatureMap)↵ | | 23 | else if (!isFeatureMap)↵
|
24 | {↵ | | 24 | {↵
|
25 | for (Object object : collection)↵ | | 25 | for (Object object : collection)↵
|
26 | {↵ | | 26 | {↵
|
27 | Entry entry = createEntry(feature, object);↵ | | 27 | Entry entry = createEntry(feature, object);↵
|
28 | entryCollection.add(entry);↵ | | 28 | entryCollection.add(entry);↵
|
29 | }↵ | | 29 | }↵
|
30 | }↵ | | 30 | }↵
|
31 | }↵ | | 31 | }↵
|
32 | else↵ | | 32 | else↵
|
33 | {↵ | | 33 | {↵
|
34 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵ | | 34 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵
|
35 | Entry [] entries = (Entry[])data;↵ | | 35 | ↵
|
36 | for (int i = 0; i < size; ++i)↵ | | 36 | for (int i = 0, size = delegateSize(); i < size; ++i)↵
|
37 | {↵ | | 37 | {↵
|
38 | Entry entry = entries[i];↵ | | 38 | Entry entry = delegateGet(i);↵
|
39 | if (validator.isValid(entry.getEStructuralFeature()))↵ | | 39 | if (validator.isValid(entry.getEStructuralFeature()))↵
|
40 | {↵ | | 40 | {↵
|
41 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵ | | 41 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵
|
42 | }↵ | | 42 | }↵
|
43 | }↵ | | 43 | }↵
|
|
44 | if (collection.size() > 1)↵ | | 44 | if (collection.size() > 1)↵
|
45 | {↵ | | 45 | {↵
|
46 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵ | | 46 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵
|
47 | }↵ | | 47 | }↵
|
|
48 | if (!isFeatureMap)↵ | | 48 | if (!isFeatureMap)↵
|
49 | {↵ | | 49 | {↵
|
50 | Entry entry = createEntry(feature, collection.iterator().next());↵ | | 50 | Entry entry = createEntry(feature, collection.iterator().next());↵
|
51 | entryCollection.add(entry);↵ | | 51 | entryCollection.add(entry);↵
|
52 | }↵ | | 52 | }↵
|
53 | }↵ | | 53 | }↵
|
|
54 | return doAddAll(entryIndex(feature, index), entryCollection); | | 54 | return doAddAll(entryIndex(feature, index), entryCollection);
|