From fa6445eb0475cb44056ba7833e8b59494cd7561c Mon Sep 17 00:00:00 2001 From: Andreas Bayha <bayha@fortiss.org> Date: Tue, 5 Dec 2023 16:14:13 +0100 Subject: [PATCH] YELLOW Issue-ref: 4349 Issue-URL: https://git.fortiss.org/af3/af3/-/issues/4349 Signed-off-by: Andreas Bayha <bayha@fortiss.org> --- .../tooling/kernel/extension/data/.ratings | 2 +- .../extension/data/PrototypeCategory.java | 26 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings index 9db0b204d..ee30ee97a 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/.ratings @@ -8,7 +8,7 @@ LogMessage.java 14204ed9d51b356f50be52362247cfbbe0cbd5c7 GREEN ModelElementTransformationContext.java 5a41bd3a75ce434c3174d50d2fdfab28b66f09f2 GREEN ModelStorageError.java 2aef480044047e960e64811111a7f27310011cc2 GREEN Prototype.java f4b13f86b7511edacc138053ffb80cecbac70868 GREEN -PrototypeCategory.java 46dd77d2481862c622e463a89cd3aae6bd3f2971 YELLOW +PrototypeCategory.java 6aa849290948b1fd9608ad06d7cca2ec6ff76805 YELLOW TransformationProviderChain.java 67ec6d0b4c23d295323572649606d79f3b897437 GREEN TutorialAtomicStep.java 09c0d6597d542b431b5bbdc790ee9e533d9f77fb GREEN TutorialCompositeStep.java cc61c2e86eff310762acac4d023fd709507355c8 GREEN diff --git a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/PrototypeCategory.java b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/PrototypeCategory.java index 46dd77d24..6aa849290 100644 --- a/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/PrototypeCategory.java +++ b/org.fortiss.tooling.kernel/src/org/fortiss/tooling/kernel/extension/data/PrototypeCategory.java @@ -16,9 +16,9 @@ package org.fortiss.tooling.kernel.extension.data; import java.util.ArrayList; -import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.Map; +import java.util.Set; /** * Container object for prototypes of a certain category. @@ -39,8 +39,8 @@ public class PrototypeCategory { /** Stores the prototypes affiliated with this category. */ private List<Prototype> children = new ArrayList<Prototype>(); - /** Stores the mapping of sub-category names to sub-categories for this category. */ - private Map<String, PrototypeCategory> subCategories = new HashMap<String, PrototypeCategory>(); + /** Stores the unique sub-categories of this category. */ + private Set<PrototypeCategory> subCategories = new HashSet<PrototypeCategory>(); /** Constructor. */ public PrototypeCategory(String category) { @@ -63,15 +63,9 @@ public class PrototypeCategory { children.add(prototype); } - /** - * Adds the given sub-category to this category. In case a sub-category of the same name already - * exists, it will be replaced. - * - * @param subCat - * The sub-{@link PrototypeCategory} to be added. - */ + /** Adds sub-category. */ public void add(PrototypeCategory subCat) { - subCategories.put(subCat.getName(), subCat); + subCategories.add(subCat); } /** Replaces an existing prototype with a new one. */ @@ -86,7 +80,7 @@ public class PrototypeCategory { public Object[] getChildren() { List<Object> result = new ArrayList<Object>(); result.addAll(children); - result.addAll(subCategories.values()); + result.addAll(subCategories); return result.toArray(); } @@ -110,4 +104,10 @@ public class PrototypeCategory { public String toString() { return "Prototype category: " + categoryName; } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + return getName().hashCode(); + } } -- GitLab