001    /*
002     * Copyright (c) 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: SubsetSupersetEObjectResolvingEList.java,v 1.3 2006/12/14 15:47:33 khussey Exp $
012     */
013    package org.eclipse.uml2.common.util;
014    
015    import org.eclipse.emf.common.notify.Notification;
016    import org.eclipse.emf.ecore.EObject;
017    import org.eclipse.emf.ecore.InternalEObject;
018    
019    /**
020     * @since 1.2
021     */
022    public class SubsetSupersetEObjectResolvingEList<E>
023                    extends SubsetSupersetEObjectEList<E> {
024    
025            private static final long serialVersionUID = 1L;
026    
027            public static class Unsettable<E>
028                            extends SubsetSupersetEObjectResolvingEList<E> {
029    
030                    private static final long serialVersionUID = 1L;
031    
032                    protected boolean isSet;
033    
034                    public Unsettable(Class<?> dataClass, InternalEObject owner,
035                                    int featureID, int[] supersetFeatureIDs, int[] subsetFeatureIDs) {
036                            super(dataClass, owner, featureID, supersetFeatureIDs,
037                                    subsetFeatureIDs);
038                    }
039    
040                    @Override
041                    protected void didChange() {
042                            isSet = true;
043                    }
044    
045                    @Override
046                    public boolean isSet() {
047                            return isSet;
048                    }
049    
050                    @Override
051                    public void unset() {
052                            super.unset();
053    
054                            if (isNotificationRequired()) {
055                                    boolean oldIsSet = isSet;
056                                    isSet = false;
057    
058                                    owner.eNotify(createNotification(Notification.UNSET, oldIsSet,
059                                            false));
060                            } else {
061                                    isSet = false;
062                            }
063                    }
064            }
065    
066            public SubsetSupersetEObjectResolvingEList(Class<?> dataClass,
067                            InternalEObject owner, int featureID, int[] supersetFeatureIDs,
068                            int[] subsetFeatureIDs) {
069                    super(dataClass, owner, featureID, supersetFeatureIDs, subsetFeatureIDs);
070            }
071    
072            @Override
073            protected boolean hasProxies() {
074                    return true;
075            }
076    
077            @SuppressWarnings("unchecked")
078            @Override
079            protected E resolve(int index, E object) {
080                    return (E) resolve(index, (EObject) object);
081            }
082    
083    }