1 | /** | | 1 | /** |
2 | * Finds a type in a model by name | | 2 | * Finds a type in a model by name |
3 | * | | 3 | * |
4 | * @param s the type name | | 4 | * FIXME: duplicated from the method with the same name in |
5 | * @param model the model | | 5 | * org.argouml.profile.internal.ModelUtils. |
6 | * @return the type or <code>null</code> if the type has not been found. | | 6 | * |
7 | */ | | 7 | * @param s the type name |
8 | public static Object findTypeInModel(String s, Object model) { | | 8 | * @param model the model |
9 | | | 9 | * @return the type or <code>null</code> if the type has not been found. |
10 | if (!Model.getFacade().isANamespace(model)) { | | 10 | */ |
11 | throw new IllegalArgumentException( | | 11 | public static Object findTypeInModel(String s, Object model) { |
12 | "Looking for the classifier " + s | | 12 | |
13 | + " in a non-namespace object of " + model | | 13 | if (!Model.getFacade().isANamespace(model)) { |
14 | + ". A namespace was expected."); | | 14 | throw new IllegalArgumentException( |
15 | } | | 15 | "Looking for the classifier " + s |
16 | | | 16 | + " in a non-namespace object of " + model |
17 | Collection allClassifiers = | | 17 | + ". A namespace was expected."); |
18 | Model.getModelManagementHelper() | | 18 | } |
19 | .getAllModelElementsOfKind(model, | | 19 | |
20 | Model.getMetaTypes().getClassifier()); | | 20 | Collection allClassifiers = |
21 | | | 21 | Model.getModelManagementHelper() |
22 | for (Object classifier : allClassifiers) { | | 22 | .getAllModelElementsOfKind(model, |
23 | if (Model.getFacade().getName(classifier) != null | | 23 | Model.getMetaTypes().getClassifier()); |
24 | && Model.getFacade().getName(classifier).equals(s)) { | | 24 | |
25 | return classifier; | | 25 | Object[] classifiers = allClassifiers.toArray(); |
26 | } | | 26 | Object classifier = null; |
27 | } | | 27 | |
28 | | | 28 | for (int i = 0; i < classifiers.length; i++) { |
29 | return null; | | 29 | |
30 | } | | 30 | classifier = classifiers[i]; |
| | | 31 | if (Model.getFacade().getName(classifier) != null |
| | | 32 | && Model.getFacade().getName(classifier).equals(s)) { |
| | | 33 | return classifier; |
| | | 34 | } |
| | | 35 | } |
| | | 36 | |
| | | 37 | return null; |
| | | 38 | } |