Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2023-08-24 12:31:22 +0000
committerVincent Lorenzo2023-09-07 08:52:39 +0000
commitb24ab0d8cf5784944c783db593c64e4ff292a55c (patch)
treea08ad3cbd2b7806e955c2469abdabc0394a85d5a
parente34e8f53ff5f06a3d1150ac8377ed4c77a0c37fa (diff)
downloadorg.eclipse.papyrus-model2doc-b24ab0d8cf5784944c783db593c64e4ff292a55c.tar.gz
org.eclipse.papyrus-model2doc-b24ab0d8cf5784944c783db593c64e4ff292a55c.tar.xz
org.eclipse.papyrus-model2doc-b24ab0d8cf5784944c783db593c64e4ff292a55c.zip
Bug 582327: [Model2Doc] Change API for AbstractTemplateToStructureMapper#handlesInput(EObject)
Change-Id: I6407bebc1fc90f4362976dd4051b8cd58fc72fdc Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src-api/org/eclipse/papyrus/model2doc/emf/template2structure/mapping/AbstractTemplateToStructureMapper.java22
-rwxr-xr-xplugins/emf/org.eclipse.papyrus.model2doc.emf.template2structure/src/org/eclipse/papyrus/model2doc/emf/template2structure/internal/mapping/TemplateToStructureMappingService.java24
2 files changed, 23 insertions, 23 deletions
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 f4f84a14..28fb18d3 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.emf.ecore.EObject;
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 @@ public abstract class AbstractTemplateToStructureMapper<INPUT extends EObject> {
* @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 fc2b0405..73239992 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.Collections;
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 @@ public final class TemplateToStructureMappingService implements IMappingService
* 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;
}
}

Back to the top