Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2020-05-27 08:44:55 +0000
committerEike Stepper2020-05-27 08:44:55 +0000
commit0a4380934a0a822f3c559a6644cfba13f2ea5c39 (patch)
tree8db10a3707a778be64caca1963815fde829f385b /plugins/org.eclipse.emf.cdo.common/src
parent5562b4be59882ce15d8e4eb5db43ea163f8a4415 (diff)
downloadcdo-0a4380934a0a822f3c559a6644cfba13f2ea5c39.tar.gz
cdo-0a4380934a0a822f3c559a6644cfba13f2ea5c39.tar.xz
cdo-0a4380934a0a822f3c559a6644cfba13f2ea5c39.zip
[Releng] Make EMFUtil.getConcreteClasses() more flexible
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java28
1 files changed, 26 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
index 31fb13e60d..215e7b41d6 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java
@@ -55,6 +55,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import java.util.function.Consumer;
/**
* Various static helper methods for dealing with EMF meta models.
@@ -372,7 +373,24 @@ public final class EMFUtil
*/
public static EClass[] getConcreteClasses(EPackage ePackage)
{
+ return getConcreteClasses(ePackage, false);
+ }
+
+ /**
+ * @since 4.10
+ */
+ public static EClass[] getConcreteClasses(EPackage ePackage, boolean includeSubPackages)
+ {
List<EClass> result = new ArrayList<>(0);
+ forAllConcreteClasses(ePackage, includeSubPackages, c -> result.add(c));
+ return result.toArray(new EClass[result.size()]);
+ }
+
+ /**
+ * @since 4.10
+ */
+ public static void forAllConcreteClasses(EPackage ePackage, boolean includeSubPackages, Consumer<EClass> consumer)
+ {
for (EClassifier classifier : ePackage.getEClassifiers())
{
if (classifier instanceof EClass)
@@ -380,12 +398,18 @@ public final class EMFUtil
EClass eClass = (EClass)classifier;
if (!eClass.isAbstract() && !eClass.isInterface())
{
- result.add(eClass);
+ consumer.accept(eClass);
}
}
}
- return result.toArray(new EClass[result.size()]);
+ if (includeSubPackages)
+ {
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ forAllConcreteClasses(subPackage, true, consumer);
+ }
+ }
}
public static EClass[] getPersistentClasses(EPackage ePackage)

Back to the top