Bug 582327: [Model2Doc] Change API for AbstractTemplateToStructureMapper#handlesInput(EObject)
Change-Id: I6407bebc1fc90f4362976dd4051b8cd58fc72fdc
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
diff --git a/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src-api/org/eclipse/papyrus/model2doc/emf/template2structure/mapping/AbstractTemplateToStructureMapper.java b/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src-api/org/eclipse/papyrus/model2doc/emf/template2structure/mapping/AbstractTemplateToStructureMapper.java
index f4f84a1..28fb18d 100755
--- a/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src-api/org/eclipse/papyrus/model2doc/emf/template2structure/mapping/AbstractTemplateToStructureMapper.java
+++ b/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src-api/org/eclipse/papyrus/model2doc/emf/template2structure/mapping/AbstractTemplateToStructureMapper.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2019, 2021 CEA LIST and others.
+ * Copyright (c) 2019, 2021, 2023 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,7 +11,7 @@
* Contributors:
* Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
* Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 570133
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 582327
*****************************************************************************/
package org.eclipse.papyrus.model2doc.emf.template2structure.mapping;
@@ -24,6 +24,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.papyrus.model2doc.emf.documentstructure.DocumentStructureFactory;
import org.eclipse.papyrus.model2doc.emf.documentstructure.DocumentStructurePackage;
+import org.eclipse.papyrus.model2doc.emf.documentstructuretemplate.DocumentStructureTemplateFactory;
/**
* Abstract class for all mappers. The extension of this class must have a constructor without parameters and be registered with the extension point structuregenerator.generator
@@ -80,8 +81,21 @@
* @return
* <code>true</code> if the EObject is handler by this mapper
*/
- private final boolean handlesInput(final EObject eobject) {
- return handlesInput(eobject.eClass());
+ @SuppressWarnings("unchecked")
+ public final boolean handlesInput(final EObject eobject) {
+ return handlesInput(eobject.eClass()) && doHandlesInput((INPUT) eobject);
+ }
+
+ /**
+ * This method can be overridden by subclass
+ *
+ * @param eobject
+ * an EObject from a {@link DocumentStructureTemplateFactory}
+ * @return
+ * <code>true</code> if the mapper is able to manage it
+ */
+ protected boolean doHandlesInput(final INPUT eobject) {
+ return true;
}
/**
diff --git a/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src/org/eclipse/papyrus/model2doc/emf/template2structure/internal/mapping/TemplateToStructureMappingService.java b/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src/org/eclipse/papyrus/model2doc/emf/template2structure/internal/mapping/TemplateToStructureMappingService.java
index fc2b040..7323999 100755
--- a/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src/org/eclipse/papyrus/model2doc/emf/template2structure/internal/mapping/TemplateToStructureMappingService.java
+++ b/plugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src/org/eclipse/papyrus/model2doc/emf/template2structure/internal/mapping/TemplateToStructureMappingService.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2019, 2020 CEA LIST and others.
+ * Copyright (c) 2019, 2020, 2023 CEA LIST and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -9,9 +9,9 @@
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
- * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
- * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 569251
- *
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ * Pauline DEVILLE (CEA LIST) pauline.deville@cea.fr - Bug 569251
+ * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Bug 582327
*****************************************************************************/
package org.eclipse.papyrus.model2doc.emf.template2structure.internal.mapping;
@@ -20,7 +20,6 @@
import java.util.List;
import java.util.ListIterator;
-import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.papyrus.model2doc.emf.template2structure.mapping.AbstractTemplateToStructureMapper;
import org.eclipse.papyrus.model2doc.emf.template2structure.mapping.IMappingService;
@@ -59,24 +58,11 @@
* the contributor answering to this mapping, or <code>null</code> when not found
*/
private AbstractTemplateToStructureMapper<?> getContributorFor(final EObject documentTemplateElement, final Class<?> expectedReturnedEClass) {
- return getContributorFor(documentTemplateElement.eClass(), expectedReturnedEClass);
- }
-
- /**
- *
- * @param eClassTemplateElement
- * the input EClass t
- * @param expectedReturnedEClass
- * the expected EClass for the result of the mapping
- * @return
- * the contributor answering to this mapping, or <code>null</code> when not found
- */
- private AbstractTemplateToStructureMapper<?> getContributorFor(final EClass eClassTemplateElement, final Class<?> expectedReturnedEClass) {
AbstractTemplateToStructureMapper<?> contributor = null;
final ListIterator<AbstractTemplateToStructureMapper<?>> iter = this.mappers.listIterator();
while (iter.hasNext() && contributor == null) {
final AbstractTemplateToStructureMapper<?> current = iter.next();
- if (current.handlesInput(eClassTemplateElement) && current.handlesExpectedOutput(expectedReturnedEClass)) {
+ if (current.handlesInput(documentTemplateElement) && current.handlesExpectedOutput(expectedReturnedEClass)) {
contributor = current;
}
}