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 | if (!entryCollection.contains(entry))↵ | | 19 | if (!entryCollection.contains(entry))↵
|
20 | {↵ | | 20 | {↵
|
21 | entryCollection.add(entry);↵ | | 21 | entryCollection.add(entry);↵
|
22 | }↵ | | 22 | }↵
|
23 | }↵ | | 23 | }↵
|
24 | }↵ | | 24 | }↵
|
25 | }↵ | | 25 | }↵
|
26 | else if (!isFeatureMap)↵ | | 26 | else if (!isFeatureMap)↵
|
27 | {↵ | | 27 | {↵
|
28 | for (Object object : collection)↵ | | 28 | for (Object object : collection)↵
|
29 | {↵ | | 29 | {↵
|
30 | Entry entry = createEntry(feature, object);↵ | | 30 | Entry entry = createEntry(feature, object);↵
|
31 | entryCollection.add(entry);↵ | | 31 | entryCollection.add(entry);↵
|
32 | }↵ | | 32 | }↵
|
33 | }↵ | | 33 | }↵
|
34 | }↵ | | 34 | }↵
|
35 | else↵ | | 35 | else↵
|
36 | {↵ | | 36 | {↵
|
37 | if (collection.size() > 1)↵ | | 37 | if (collection.size() > 1)↵
|
38 | {↵ | | 38 | {↵
|
39 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵ | | 39 | throw new IllegalArgumentException("The multiplicity constraint is violated");↵
|
40 | }↵ | | 40 | }↵
|
|
41 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵ | | 41 | FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature);↵
|
42 | Entry [] entries = (Entry[])data;↵ | | 42 | ↵
|
43 | for (int i = 0; i < size; ++i)↵ | | 43 | for (int i = 0, size = delegateSize(); i < size; ++i)↵
|
44 | {↵ | | 44 | {↵
|
45 | Entry entry = entries[i];↵ | | 45 | Entry entry = delegateGet(i);↵
|
46 | if (validator.isValid(entry.getEStructuralFeature()))↵ | | 46 | if (validator.isValid(entry.getEStructuralFeature()))↵
|
47 | {↵ | | 47 | {↵
|
48 | if (collection.contains(isFeatureMap ? entry : entry.getValue()))↵ | | 48 | if (collection.contains(isFeatureMap ? entry : entry.getValue()))↵
|
49 | {↵ | | 49 | {↵
|
50 | return false;↵ | | 50 | return false;↵
|
51 | }↵ | | 51 | }↵
|
52 | else↵ | | 52 | else↵
|
53 | {↵ | | 53 | {↵
|
54 | for (Object object : collection)↵ | | 54 | for (Object object : collection)↵
|
55 | {↵ | | 55 | {↵
|
56 | doSet(i, isFeatureMap ? (Entry)object : createEntry(feature, object));↵ | | 56 | doSet(i, isFeatureMap ? (Entry)object : createEntry(feature, object));↵
|
57 | }↵ | | 57 | }↵
|
58 | return true;↵ | | 58 | return true;↵
|
59 | }↵ | | 59 | }↵
|
60 | }↵ | | 60 | }↵
|
61 | }↵ | | 61 | }↵
|
62 | if (!isFeatureMap)↵ | | 62 | if (!isFeatureMap)↵
|
63 | {↵ | | 63 | {↵
|
64 | Entry entry = createEntry(feature, collection.iterator().next());↵ | | 64 | Entry entry = createEntry(feature, collection.iterator().next());↵
|
65 | entryCollection.add(entry);↵ | | 65 | entryCollection.add(entry);↵
|
66 | }↵ | | 66 | }↵
|
67 | }↵ | | 67 | }↵
|
|
68 | return doAddAll(entryCollection); | | 68 | return doAddAll(entryCollection);
|