/******************************************************************************* * Copyright (c) 2013 Obeo. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Obeo - initial API and implementation *******************************************************************************/ package org.eclipse.emf.compare.uml2.internal.postprocessor.extension.clazz; import static com.google.common.base.Predicates.instanceOf; import com.google.common.collect.Iterables; import java.util.LinkedHashSet; import java.util.Set; import org.eclipse.emf.compare.Diff; import org.eclipse.emf.compare.uml2.internal.GeneralizationSetChange; import org.eclipse.emf.compare.uml2.internal.UMLCompareFactory; import org.eclipse.emf.compare.uml2.internal.UMLDiff; import org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.util.Switch; import org.eclipse.uml2.uml.GeneralizationSet; /** * Factory for Generalization set changes. * * @author <a href="mailto:cedric.notot@obeo.fr">Cedric Notot</a> */ public class UMLGeneralizationSetChangeFactory extends AbstractUMLChangeFactory { /** * {@inheritDoc} * * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#getExtensionKind() */ @Override public Class<? extends UMLDiff> getExtensionKind() { return GeneralizationSetChange.class; } /** * {@inheritDoc} * * @see org.eclipse.emf.compare.internal.postprocessor.factories.AbstractChangeFactory#createExtension() */ @Override public UMLDiff createExtension() { return UMLCompareFactory.eINSTANCE.createGeneralizationSetChange(); } /** * {@inheritDoc} * * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminant(org.eclipse.emf.compare.Diff) */ @Override protected EObject getDiscriminant(Diff input) { return Iterables.find(getDiscriminants(input), instanceOf(GeneralizationSet.class), null); } /** * {@inheritDoc} * * @see org.eclipse.emf.compare.uml2.internal.postprocessor.AbstractUMLChangeFactory#getDiscriminantsGetter() */ @Override protected Switch<Set<EObject>> getDiscriminantsGetter() { return new DiscriminantsGetter() { @Override public Set<EObject> caseGeneralizationSet(GeneralizationSet object) { Set<EObject> result = new LinkedHashSet<EObject>(); result.add(object); return result; } }; } }