001    /*
002     * Copyright (c) 2003, 2006 IBM Corporation and others.
003     * All rights reserved.   This program and the accompanying materials
004     * are made available under the terms of the Eclipse Public License v1.0
005     * which accompanies this distribution, and is available at
006     * http://www.eclipse.org/legal/epl-v10.html
007     *
008     * Contributors:
009     *   IBM - initial API and implementation
010     *
011     * $Id: SubsetEObjectContainmentEList.java,v 1.4 2006/12/14 15:47:33 khussey Exp $
012     */
013    package org.eclipse.uml2.common.util;
014    
015    import java.util.ArrayList;
016    import java.util.Collection;
017    
018    import org.eclipse.emf.common.notify.Notification;
019    import org.eclipse.emf.ecore.EObject;
020    import org.eclipse.emf.ecore.InternalEObject;
021    
022    @Deprecated
023    public class SubsetEObjectContainmentEList<E>
024                    extends SubsetEObjectEList<E> {
025    
026            private static final long serialVersionUID = 1L;
027    
028            public static class Unsettable<E>
029                            extends SubsetEObjectContainmentEList<E> {
030    
031                    private static final long serialVersionUID = 1L;
032    
033                    public static class Resolving<E>
034                                    extends Unsettable<E> {
035    
036                            private static final long serialVersionUID = 1L;
037    
038                            public Resolving(Class<?> dataClass, InternalEObject owner,
039                                            int featureID, int[] supersetFeatureIDs) {
040                                    super(dataClass, owner, featureID, supersetFeatureIDs);
041                            }
042    
043                            public Resolving(Class<?> dataClass, InternalEObject owner,
044                                            int featureID, int supersetFeatureID) {
045                                    this(dataClass, owner, featureID, new int[]{supersetFeatureID});
046                            }
047    
048                            @Override
049                            protected boolean hasProxies() {
050                                    return true;
051                            }
052    
053                            @SuppressWarnings("unchecked")
054                            @Override
055                            protected E resolve(int index, E object) {
056                                    return (E) resolve(index, (EObject) object);
057                            }
058                    }
059    
060                    protected boolean isSet;
061    
062                    public Unsettable(Class<?> dataClass, InternalEObject owner,
063                                    int featureID, int[] supersetFeatureIDs) {
064                            super(dataClass, owner, featureID, supersetFeatureIDs);
065                    }
066    
067                    public Unsettable(Class<?> dataClass, InternalEObject owner,
068                                    int featureID, int supersetFeatureID) {
069                            this(dataClass, owner, featureID, new int[]{supersetFeatureID});
070                    }
071    
072                    @Override
073                    protected void didChange() {
074                            isSet = true;
075                    }
076    
077                    @Override
078                    public boolean isSet() {
079                            return isSet;
080                    }
081    
082                    @Override
083                    public void unset() {
084                            super.unset();
085    
086                            if (isNotificationRequired()) {
087                                    boolean oldIsSet = isSet;
088                                    isSet = false;
089    
090                                    owner.eNotify(createNotification(Notification.UNSET, oldIsSet,
091                                            false));
092                            } else {
093                                    isSet = false;
094                            }
095                    }
096            }
097    
098            public static class Resolving<E>
099                            extends SubsetEObjectContainmentEList<E> {
100    
101                    private static final long serialVersionUID = 1L;
102    
103                    public Resolving(Class<?> dataClass, InternalEObject owner,
104                                    int featureID, int[] supersetFeatureIDs) {
105                            super(dataClass, owner, featureID, supersetFeatureIDs);
106                    }
107    
108                    public Resolving(Class<?> dataClass, InternalEObject owner,
109                                    int featureID, int supersetFeatureID) {
110                            this(dataClass, owner, featureID, new int[]{supersetFeatureID});
111                    }
112    
113                    @Override
114                    protected boolean hasProxies() {
115                            return true;
116                    }
117    
118                    @SuppressWarnings("unchecked")
119                    @Override
120                    protected E resolve(int index, E object) {
121                            return (E) resolve(index, (EObject) object);
122                    }
123            }
124    
125            public SubsetEObjectContainmentEList(Class<?> dataClass,
126                            InternalEObject owner, int featureID, int[] supersetFeatureIDs) {
127                    super(dataClass, owner, featureID, supersetFeatureIDs);
128            }
129    
130            public SubsetEObjectContainmentEList(Class<?> dataClass,
131                            InternalEObject owner, int featureID, int supersetFeatureID) {
132                    this(dataClass, owner, featureID, new int[]{supersetFeatureID});
133            }
134    
135            @Override
136            protected boolean hasInverse() {
137                    return true;
138            }
139    
140            @Override
141            protected boolean hasNavigableInverse() {
142                    return false;
143            }
144    
145            @Override
146            protected boolean isContainment() {
147                    return true;
148            }
149    
150            @Override
151            public boolean addAll(Collection<? extends E> collection) {
152                    return super.addAll(new ArrayList<E>(collection));
153            }
154    
155            @Override
156            public boolean addAll(int index, Collection<? extends E> collection) {
157                    return super.addAll(index, new ArrayList<E>(collection));
158            }
159    
160    }