Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CopyHelperEUMLImpl |
|
| 3.5;3.5 |
1 | // $Id: CopyHelperEUMLImpl.java 18220 2010-04-08 20:37:15Z tfmorris $ | |
2 | /******************************************************************************* | |
3 | * Copyright (c) 2007,2010 Bogdan Pistol and other contributors | |
4 | * All rights reserved. This program and the accompanying materials | |
5 | * are made available under the terms of the Eclipse Public License v1.0 | |
6 | * which accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bogdan Pistol - initial implementation | |
11 | *******************************************************************************/ | |
12 | package org.argouml.model.euml; | |
13 | ||
14 | import org.argouml.model.CopyHelper; | |
15 | import org.eclipse.uml2.uml.Element; | |
16 | ||
17 | /** | |
18 | * The implementation of the CopyHelper for EUML2. | |
19 | */ | |
20 | 0 | class CopyHelperEUMLImpl implements CopyHelper { |
21 | ||
22 | /** | |
23 | * The model implementation. | |
24 | */ | |
25 | private EUMLModelImplementation modelImpl; | |
26 | ||
27 | /** | |
28 | * Constructor. | |
29 | * | |
30 | * @param implementation | |
31 | * The ModelImplementation. | |
32 | */ | |
33 | 0 | public CopyHelperEUMLImpl(EUMLModelImplementation implementation) { |
34 | 0 | modelImpl = implementation; |
35 | 0 | } |
36 | ||
37 | public Element copy(Object source, Object destination) { | |
38 | 0 | if (!(source instanceof Element) || !(destination instanceof Element)) { |
39 | 0 | throw new IllegalArgumentException( |
40 | "The source and destination must be instances of Element"); //$NON-NLS-1$ | |
41 | } | |
42 | 0 | Element copiedElement = UMLUtil.copy( |
43 | modelImpl, (Element) source, (Element) destination); | |
44 | 0 | if (copiedElement == null) { |
45 | 0 | throw new UnsupportedOperationException( |
46 | "Could not copy " + source + " to destination " + destination); //$NON-NLS-1$//$NON-NLS-2$ | |
47 | } | |
48 | 0 | return copiedElement; |
49 | } | |
50 | ||
51 | ||
52 | } |