Skip to content
Snippets Groups Projects
Commit c6375dcd authored by Andreas Bayha's avatar Andreas Bayha
Browse files

Rollback of ElementCompositorBase (used in variability)

refs 2998
parent 0bf7cdb2
No related branches found
No related tags found
No related merge requests found
/*-------------------------------------------------------------------------+
| Copyright 2014 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.extension.base;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.fortiss.tooling.kernel.extension.IElementCompositor;
import org.fortiss.tooling.kernel.extension.data.IElementCompositionContext;
import org.fortiss.tooling.kernel.extension.data.Prototype;
/**
* Base implementation for supporting composition of {@link IElementCompositor}.
*
* This class is used for example in the variability plugin.
*
* @author moudy
*/
public abstract class ElementCompositorBase<C extends EObject> implements IElementCompositor<C> {
/** {@inheritDoc} */
@Override
public boolean canCompose(C container, EObject contained, IElementCompositionContext context) {
return isCorrectClass(contained);
}
/** {@inheritDoc} */
@Override
public boolean canComposePrototype(Prototype prototype) {
return isCorrectClass(prototype.getPrototype());
}
/** Returns true if the contained object is an instance of an acceptable class. */
protected abstract boolean isCorrectClass(EObject contained);
/** {@inheritDoc} */
@Override
abstract public boolean compose(C container, EObject contained,
IElementCompositionContext context);
/** {@inheritDoc} */
@Override
public boolean canDecompose(EObject contained) {
return isCorrectClass(contained);
}
/** {@inheritDoc} */
@Override
public boolean decompose(EObject contained) {
EcoreUtil.delete(contained, true);
return true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment